我在编写一个将类映射到简单表视图的小 GUI 库时遇到了这个问题。某种类型的每个类成员 = 列,列的顺序很重要。但...
class Person(object):
name = None
date_of_birth = None
nationality = None
gender = None
address = None
comment = None
for member in Person.__dict__.iteritems():
if not member[1]:
print member[0]
输出:
comment
date_of_birth
name
address
gender
nationality
...
呃,奥德都搞混了……期望的输出:
name
date_of_birth
nationality
gender
address
comment
有没有办法在不维护额外OrderedDict()
列的情况下做到这一点?