标签:int style rank 取值 code 字符串 列表 -- 类型
列表的表现形式:其中的元素可以使任何数据类型,像 字符串,数字, 字典, 列表,变量 等任何类型
age = 28
name = ["Frank", "Lee",age,["Andy","Troy"]]
>>> age=2 >>> name = ["Frank", "Lee",age,["Andy","Troy"]] >>> print(name) [‘Frank‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘]]
# 列表下标取值和分片 >>> name[0] ‘Frank‘ >>> name[0:2] [‘Frank‘, ‘Lee‘] >>> name[-4:] [‘Frank‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘]]
>>> name[:] [‘Frank‘, ‘Lee‘, 2, [‘Andy‘, ‘Troy‘]] >>> name[-4:][3] [‘Andy‘, ‘Troy‘] >>> name[-4:][3][0] ‘Andy‘ >>> name[-4:][3][0] ‘Andy‘ >>> name[-4:][3][0] ‘Andy‘ >>> name[-4:][3][0] ‘Andy‘ >>> name[-4:][3][0][0] ‘A‘
标签:int style rank 取值 code 字符串 列表 -- 类型
原文地址:http://www.cnblogs.com/frankb/p/6104295.html