我正在尝试使用排序对象列表
my_list.sort(key=operator.attrgetter(attr_name))
但如果有任何列表项attr = None而不是attr = 'whatever',
attr = None
attr = 'whatever'
然后我得到了 TypeError: unorderable types: NoneType() < str()
TypeError: unorderable types: NoneType() < str()
在Py2中,这不是问题.我如何在Py3中处理这个?
python python-2to3 python-3.x
python ×1
python-2to3 ×1
python-3.x ×1