6.121序列类型及操作·元组是序列类型的一种扩展·与字符串一样,元组的元素一旦创建就不能被修改·使用小括号)或tuple()创建,元素间用逗号,分隔·可以使用或不使用小括号def func():return 1,2
21 • 元组是序列类型的一种扩展 • 与字符串一样,元组的元素一旦创建就不能被修改 • 使用小括号 () 或 tuple() 创建,元素间用逗号 , 分隔 • 可以使用或不使用小括号 6.1 序列类型及操作 def func(): return 1,2
6.122序列类型及操作·元组类型的定义>>>creature="cat","dog","tiger","human">>>creature('cat',dog',"tiger',""human')>>>color=(0x001100,"blue",creature)>>> color(4352,blue',('cat','dog','tiger','human'))
22 • 元组类型的定义 >>> creature = "cat", "dog", "tiger", "human" >>> creature ('cat', 'dog', 'tiger', 'human') >>> color = (0x001100, "b l u e ", c r e a t u r e ) >>> color ( 4 3 5 2 , ' b l u e ' , ( ' c a t ' , ' d o g ' , ' t i g e r ' , ' h u m a n ' ) ) 6.1 序列类型及操作
6.123序列类型及操作·元组继承序列类型的全部通用操作·元组继承了序列类型的全部通用操作·元组因为创建后不能修改,因此没有特殊操作·使用或不使用小括号
23 • 元组继承序列类型的全部通用操作 • 元组继承了序列类型的全部通用操作 • 元组因为创建后不能修改,因此没有特殊操作 • 使用或不使用小括号 6.1 序列类型及操作
6.124序列类型及操作·元组类型的操作creature ="cat","dog","tiger","human">>>>>> creature[::-1]('human','tiger',,dog','cat')color =(0x001100,"blue",creature)>>>>>> color[-1][2]'tiger'一个元组可以作为另一个元组的元素
24 • 元组类型的操作 >>> creature = "cat", "dog", "tiger", "human" >>> creature[::-1] (' h uma n ', ' ti ger ' , ' d og ', ' ca t’ ) >>> color = (0x001100, "blue", creature) >>> color[-1][2] 'tiger’ • 一个元组可以作为另一个元组的元素 6.1 序列类型及操作
6.1.4列表类型及操作
6.1.4 列表类型及操作