第 013讲: 元组tuple 上了枷锁的列表

课后作业:

0.
列表: 你可以随时往里面添加和删除任何东西
元组: 不可修改的序列(封闭的列表,一旦定义,就不可改变,不能添加修改和删除)

1. 内容不轻易改写的时候,使用元组

2. 救列表,列表的功能更加强大
3. 元组可以使用的方法:
count和index
4. 插入一个数值的时候

>>> temp2 = temp[:2] + temp('意境',) + temp[2:]
>>> temp = temp[:2] + ('意境',) + temp[2:]
>>> temp

 3.

4. 

5.

5.
>>> x,y,z = 1,2,3
>>> type(y)
<class 'int'>
>>> type(z)
<class 'int'>

>>> type(x)
<class 'int'>
>>> h = x,y,z
>>> type(h)
<class 'tuple'>

6.

原文地址:https://www.cnblogs.com/jiangkeji/p/9034312.html