python学习笔记1:元组

元组类似于列表,不同之处在于元组不能修改

1、元组的创建

>>>ages_1=(11,22,33,44,55)
#
>>>ages_2=tuple((11,22,33,44,55))

2、元组的基本操作

#查找
>>>ages_1=(11,22,33,44,55)
>>>ages_1[0]
11
>>>ages_1[-1]
55

#循环
>>>for age in ages_1
    
        print(age)
11
22
33
44
55

#长度
>>>len(age)
5

猜你喜欢

转载自www.cnblogs.com/Triw/p/9214676.html