跳至内容
Python 俱乐部
用户工具
登录
站点工具
搜索
工具
显示页面
修订记录
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您的足迹:
python-basic:list
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
====== Python 列表(list)操作 ====== ===== 创建列表 ===== <code python> sample_list = ['a',1,('a','b')] </code> ===== Python 列表操作 ===== <code python> sample_list = ['a','b',0,1,3] </code> ==== 得到列表中的某一个值 ==== <code python> value_start = sample_list[0] end_value = sample_list[-1] </code> ==== 删除列表的第一个值 ==== <code python> del sample_list[0] </code> ==== 在列表中插入一个值 ==== <code python> sample_list[0:0] = ['sample value'] </code> ==== 得到列表的长度 ==== <code python> list_length = len(sample_list) </code> ==== 列表遍历 ==== <code> for element in sample_list: print(element) </code> ===== Python 列表高级操作/技巧 ===== ==== 产生一个数值递增列表 ==== <code python> num_inc_list = range(30) #will return a list [0,1,2,...,29] </code> ==== 用某个固定值初始化列表 ==== <code python> initial_value = 0 list_length = 5 sample_list = [ initial_value for i in range(10)] sample_list = [initial_value]*list_length # sample_list ==[0,0,0,0,0] </code>
python-basic/list.txt
· 最后更改: 2010/06/02 01:18 (外部编辑)
页面工具
显示页面
修订记录
反向链接
回到顶部