📜  如何在python代码示例中打印类属性

📅  最后修改于: 2022-03-11 14:46:32.551000             🧑  作者: Mango

代码示例2
an = Animal()
attrs = vars(an)
# {'kids': 0, 'name': 'Dog', 'color': 'Spotted', 'age': 10, 'legs': 2, 'smell': 'Alot'}
# now dump this in some way or another
print(', '.join("%s: %s" % item for item in attrs.items()))