1,"修改元组"a=(1,2,3)
>>>
b=(1,2,3)
>>>
c="c"
>>>
d=[1,2,3,'d']
>>>
a=(b,1,2,3,c,d)
>>> a
((1, 2, 3), 1, 2, 3,
'c', [1, 2, 3, 'd'])
2,"可变"元组>>>
a=(1,2,3,[1,2,3])
>>>
a[3][0]='a'
>>>
a[3][1]='b'
>>>
a[3][2]='c'
>>> a
(1, 2, 3, ['a', 'b',
'c'])
3,解包赋值>>>
tuple=('a','b','c')
>>>
x,y,z=tuple
>>> x,y,z
('a', 'b', 'c')
>>> x
'a'
>>> y
'b'
>>> z
'c'
4,元组遍历>>>
tuple=(1,2,3,4,5,6,7,8,9,0)
>>> for item
in range(len(tuple)):
... print tuple[item],
...
1 2 3 4 5 6 7 8 9 0
>>>
>>>
i=(1,2,3,4)
>>> for j in
i:
... print j,
...
1 2 3 4
>>>