NAME,AGE,SEX,EMAIL(4)
student= ('jim',16,'male','jim123@.com')
#name
print student [NAME]
#age
if student[AGE]>16:
pass
#sex
if student [SEX]=='male':
pass
student= ('jim',16,'male','jim123@.com')
from collections import namedtuple
student = namedtuple('student','name','age','sex','email')
s= student ('jim',16,'male','jim123@.com')
s
s2=student(name='jim',age=16,sex='male',email='jim123@.com')
s.name
'jim'
s.age
16
Python高级编程-如何为元祖中的每个元素命名,提高程序可读性?
最新推荐文章于 2024-05-28 09:05:19 发布