from mrjob.py2 import xrange student = ('Jim', 16, 'male', 'jim8721@gmail.com') print(student[0]) # NAME = 0 # AGE = 1 # GENDER = 2 # EMAIL = 3 NAME, AGE, GENDER, EMAIL = xrange(4) print(student[NAME]) from collections import namedtuple Student = namedtuple('Student', ['name', 'age', 'gender', 'email']) s = Student('Jim', 16, 'male', 'jim8721@gmail.com') print(s) print(s.name) # 关键字传参 s2 = Student(name='Jim', age=16, gender='male', email='jim8721@gmail.com') print(s2) print(s2.name) print(isinstance(s, tuple))