python namedtuple命名元组

from collections import namedtuple
Animal=namedtuple('Animal','name age type')
perry=Animal(name='perry',age=1,type='cat')
print(perry.type)
print(perry[0])
print(perry._asdict())

原文地址:https://www.cnblogs.com/mahailuo/p/10201648.html