python 为每个元组元素命名
代码:
#!/usr/bin/env python #-*- coding: utf-8 -*- from collections import namedtuple Student = namedtuple('Student',['name','age','email']) s = Student('jim','16','14@qq.com') print(s.name)
代码:
#!/usr/bin/env python #-*- coding: utf-8 -*- from collections import namedtuple Student = namedtuple('Student',['name','age','email']) s = Student('jim','16','14@qq.com') print(s.name)