我很难想出一个灵巧的方法来处理这种情况.我从数据库读回来的数据.我想对accoutingdate进行评论.但是,accoutingdate有时可能为空.我目前正在做以下事情:
results = sorted(results, key=operator.itemgetter('accountingdate'), reverse=True)
Run Code Online (Sandbox Code Playgroud)
但是,由于一些accoutingdates为null,这种炸弹的"TypeError:无法将datetime.date与NoneType进行比较".
什么是"最正确"或"最恐怖"的方式来处理这个问题?