就是这个tuple啊,这个混蛋tuple是不能修改的。
tuple=('曹操','刘备','孙权')
print(tuple[0])
print(tuple[1])
print(tuple[2])
和前面那个列表的输出是一模一样的!
TypeError: 'tuple' object does not support item assignment
TypeError: 'tuple' object does not support item assignment
--------------------------------------------------------------------------------------------
tuple=('曹操','刘备','孙权')
tuple2=("吴佩孚","孙传芳","张作霖")
tuple3=tuple2+tuple
i=0
temp=len(tuple3)
while i<temp:
print(tuple3[i],end=" ")
i+=1
---------------------------------------------------------------------------------------------------
tuplex=tuple(list)
TypeError: 'tuple' object is not callable
list=['s','ss','sunqicheng']
tuplex=tuple(list)
print(tuplex)
#现在已经不能直接将list转化为tuple了。