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())

python namedtuple命名元组-LMLPHP

05-08 08:17