元组的定义
t1 =(1,"hello",True)
t2=()
t3=tuple()
t4=("hello",)
print(f"t4的数据类型{type(t4)},t4的内容是{t4}")
t5=((1,2,3),(4,5,6))
print(f"t5的类型是{type(t5)}")
print(f"{t5[1][2]}")
元组的方法
t6=("jack","tom","jarry","tom")
index =t6.index("tom")
print(f"{index}")
num=t6.count("tom")
print(f"t6中tom的数量是{num}个")
num=len(t6)
print(f"t6中元素的数量是{num}个")
元组的遍历
index = 0
while index <len(t6):print(f"{t6[index]}")index+=1for element in t6:print(f"元素有{element}",end='')
元组的特点
t7=(1,2,["aaaa","bbbb"])
t7[2][0]="cccc"print(f"{t7}")"""
可以容纳多个数据
可以容纳不同类型的数据
数据有序存储
允许重复数据存在
不可以修改元素
支持for循环
"""