1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| student=('Jim','16','male','Jim123@qq.com')
print(student[0])
print(student[1])
print(student[2])
print(student[3])
|
Jim
16
male
Jim123@qq.com
方法一:利用对下标索引赋值,达到有意义
1 2 3 4 5 6 7 8 9 10 11 12 13
| NAME,AGE,SEX,EMAIL = range(0,4)
print(student[NAME])
print(student[AGE])
print(student[SEX])
print(student[EMAIL])
|
Jim
16
male
Jim123@qq.com
方法二:collections 模块 namedtuple 方法
1 2 3 4 5
| from collections import namedtuple student = namedtuple('student',['name','age','sex','email']) s = student('Jim','16','male','Jim123@qq.com') s.name
|
'Jim'
'male'
'16'
'Jim123@qq.com'