我的CSDN | 我的51CTO

命名元组nametuple

# coding:utf-8

from collections import namedtuple

Student = namedtuple('Student', ['no', 'name', 'age', 'sex'])
student = Student("2016214338", u"张三", 19, u"")
print student.name
print student.age

-----结果显示--------------------

张三
19

 

posted @ 2017-04-13 12:44  smileyes  阅读(260)  评论(0编辑  收藏  举报