访问元组

元组可以使用下标索引来访问元组中的值,如下实例:

实例

tup1 = ('physics', 'chemistry', 1997, 2000)
tup2 = (1, 2, 3, 4, 5, 6, 7 )

 

print ("tup1[0]: ", tup1[0])
print ("tup2[1:5]: ", tup2[1:5])