注意元组是小括号,而且元祖只有两个功能count和index

>>> t=(1,2,3,4)

>>> dir(t)

['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index']

>>> 


元祖转换成列表

>>> type(t)

>>> a=list(t)

>>> type(a)


列表转换成元祖

>>> a

[1, 2, 3, 4]

>>> type(a)

>>> t=tuple(a)

>>> t

(1, 2, 3, 4)

>>> type(t)