liuyangak

python第2练--list和tuple

作为类似数组的数据结构

 

list 用 =[...] 赋值,list的内容可变

如:

classmates = ['Michael', 'Bob', 'Tracy']

 

tuple 用 =(...)赋值,tuple定义后内容不可变

如:

t = (1, 2)

注意,如果定义只有一个元素的tuple 必须用 t = (1,) 不能忘记逗号

posted on 2015-02-27 17:27  liuyangak  阅读(88)  评论(0)    收藏  举报

导航