- collections.nametuple()
eg:
import collections
#定义一个namedtuple
Employee = collections.namedtuple('Employee',['name', 'age', 'gender', 'job'])
#调用
employeeJob = Employee('Job', 22, 'male', 'student')
应用方法
print(employeeJob.name,employeeJob.age,employeeJob.gender,employeeJob.job)
输出结果
job 22 male student