Python 可命名元祖

1 import collections
2 MytupleClass = collections.namedtuple('MytupleClass',['x','y','z'])
3 obj = MytupleClass(11,22,33)
4 print(obj)
5 print(obj.x)
6 print(obj.y)
7 print(obj.z)

  MytupleClass(x=11, y=22, z=33)
  11
  22
  33

posted @ 2018-06-11 22:17  Presley  阅读(255)  评论(0编辑  收藏  举报