python列表操作使用示例分享
2014-02-21 15:31
751 查看
Python 3.3.4 (v3.3.4:7ff62415e426, Feb 10 2014, 18:13:51) [MSC v.1600 64 bit (AMD64)] on win32Type "copyright", "credits" or "license()" for more information.>>> cast=["cleese","palin","jones","idle"]>>> print(cast)['cleese', 'palin', 'jones', 'idle']>>> print(len(cast))#显示数据项数量4>>> print(cast[1])#显示列表中第2个数据项的值palin>>> cast.append("gilliam")#在列表末尾添加一个数据项>>> print(cast)['cleese', 'palin', 'jones', 'idle', 'gilliam']>>> cast.pop()#删除列表末尾的数据项'gilliam'>>> print(cast)['cleese', 'palin', 'jones', 'idle']>>> cast.extend(["gilliam","chapman"])#在列表末尾增加一个数据项集合>>> print(cast)['cleese', 'palin', 'jones', 'idle', 'gilliam', 'chapman']>>> cast.remove("chapman")#删除指定的数据项>>> print(cast)['cleese', 'palin', 'jones', 'idle', 'gilliam']>>> cast.insert(0,"chapman")#在指定的位置增加数据项>>> print(cast)['chapman', 'cleese', 'palin', 'jones', 'idle', 'gilliam']>>>
相关文章推荐
- python列表操作使用示例分享
- 两个使用Python脚本操作文件的小示例分享
- Python列表和元组的定义与使用操作示例
- python文件读写并使用mysql批量插入示例分享(python操作mysql)
- python文件读写并使用mysql批量插入示例分享(python操作mysql)
- 两个使用Python脚本操作文件的小示例分享
- java使用jdbc操作数据库示例分享
- Python List(列表)使用示例
- python列表操作实例源码讲解(创建、使用、更新、删除)
- PYTHON文件操作和列表的使用
- Python常见排序操作示例【字典、列表、指定元素等】
- python操作列表的函数使用代码详解
- 使用python统计文件行数示例分享
- Python中列表与元组的乘法操作示例
- Python操作列表之List.insert()方法的使用
- Python操作列表的常用方法分享
- Python使用jsonpath-rw模块处理Json对象操作示例
- 应用程序操作NorFlash示例代码分享(norflash接口使用方法)
- python使用cookielib库示例分享
- Python使用matplotlib和pandas实现的画图操作【经典示例】