python-namedtuple命名元组

from collections import namedtuple
MyTupleClass = namedtuple('MyTupleClass',['name', 'age', 'job'])
obj = MyTupleClass("Tomsom",12,'Cooker')
print(obj.name)
print(obj.age)
print(obj.job)

output:

D:\soft\python36\python.exe D:/myproject/demo/log/test.py
Tomsom
12
Cooker

 

posted @ 2019-08-21 18:59  爱打盹的猫猫  阅读(145)  评论(0编辑  收藏  举报