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

 

posted on 2018-12-31 11:25  hailuo  阅读(215)  评论(0编辑  收藏  举报