python中的元组和多为容器

时间:2025-09-14 22:33:46  阅读量:  分类:标签:


#元组
#特性:有序;元素值可以重复;可以存放多种数据类型;不支持修改
tuplea=("张三","李四","王五","赵六")
tuplea=("张三","李四","王五","赵六")
print(tuplea[3])
print(tuplea[-3])
print(tuplea[1:3])
#元组用于对安全性有一定需求的数据上
#多维容器
lista=[1,3,4,5,8,89,9]
listb=[13,4,43,5,"你好",(13,24,24,"北京",5),776,56]
listc=[21,3,465,7676,86]
listx=[lista,listb,listc,[1,2,33,3],"abc"]
print(listx[1][5][3])