Python 3.6.0 (V3.6.0:41df79263a11, Dec, 07:18:10) [MSC v.1900 + bit (Intel)] on Win32
Type "Copyright", "credits" or "license ()" For more information.
>>> tuple_1 = (1, ' A ', 2, "B", 3, ' C ')
>>> Tuple_1
(1, ' A ', 2, ' B ', 3, ' C ')
>>> tuple_1 = (1, ' A ', (2, "B"), 3, ' C ')
>>> Tuple_1
(1, ' A ', (2, ' B '), 3, ' C ')
>>> Tuple_1[0]
1
>>> Tuple_1[2][0]
2
>>> tuple_1[2:]
((2, ' B '), 3, ' C ')
>>> Tuple_1[:2]
(1, ' a ')
>>> tuple_1[:]
(1, ' A ', (2, ' B '), 3, ' C ')
>>> tuple_2=tuple_1[:]
>>> tuple_2[0]=4
Traceback (most recent):
File "<pyshell#12>", line 1, in <module>
Tuple_2[0]=4
TypeError:' tuple ' object does not support item assignment
>>> tmp= (at)
>>> Type (TMP)
<class ' int ' >
>>> tmp2=1,2
>>> Type (TMP2)
<class ' tuple ' >
>>> #是不是tuple类型关键是逗号而不是小括号
>>> tmp3=[]
>>> Type (Tmp3)
<class ' list ' >
>>> #是不是list类型只要看有没有中括号
>>> tmp4= ()
>>> Type (tmp4)
<class ' tuple ' >
>>> #如果只有小括号而无逗号就是空元组
>>> tmp5= (1,)
>>> Type (TMP5)
<class ' tuple ' >
>>> TMP5
(1,)
>>> Tmp6=1,
>>> Type (TMP6)
<class ' tuple ' >
>>> 6* (6,)
(6, 6, 6, 6, 6, 6)
>>> type (6,)
<class ' int ' >
>>> tmp= (' Sweeping monk ', ' Zhang San Feng ', "Wind Qing", "Stone Break Day")
>>>tmp=tmp[:2]+ (' Guo Jing ',) +tmp[2:]
>>> tmp
(' Sweeping monk ', ' Zhang Sanfeng ', ' Guo Jing ', ' Wind Qing ', ' stone Broken Day ')
>>> #原来的tmp还存在, but no name tag affixed, will be automatically recycled by Python
>>> del tmp
>>> tmp
Traceback (most recent):
File "<pyshell#36>", line 1, in <module>
Tmp
Nameerror:name ' tmp ' is not defined
>>> #python有回收机制, no need to use Del to remove the active, no sticker will be automatically recycled
Python tuple