元组的创建
t = ('hello', 'world', 99) # 直接括号()
print(t)
print(type(t)) # 查看类型
t1 = tuple(('python', 'hello', 99)) # 使用内置函数tuple()创建元组
t2 = (10,) # 只有一个元素时,需要括号加逗号 ( ,)
t3 = () # 空元组的创建
t4 = tuple()
* 元组没有增删查改
元组的遍历
t = (10, [20, 30], 40)
print(t[0])
t[1].append(100) # t[1]是列表,可以添加元素
item = (10, [20, 30], 40)
for t in item: # 元组的遍历
print(t)