Python namedtuple的使用

分类-学习笔记 浏览-1446 评论-0
标签:

namedtuple: factory function for creating tuple subclasses with named fields.

from collections import namedtuple

代码示例

Point = namedtuple('Point', 'x y', verbose=True)
point = Point(1,2)
print point.x,point.y

添加留言