元组的创建:
第一种方式,使用() #小括号可以省略
t=('python','world',98)
print(t)
print(type(t))
第二种创建方式,使用内置函数tuple()
t1=tuple(‘pyhon’,‘world’,98)
print(t1)
只包含一个元组的元素需要使用逗号和小括号
t=(10,)
空列表: lst=[]
lst1=list()
空字典: d={}
d2=dict()
空元组: t4=()
t3=tuple()
t=(10,[20,30],40)
由于【20,30】列表,而列表是可变序列,所以可以向列中添加元素,而列表的内存地址不变
t【1】.append(100)
元组的遍历
t=('python','world',98)
第一种获取元组元素的方式,使用索引:print(t[0])
第二种 遍历: for item in t :
print(item)