python 列表的增删改查操做1125 元组 的查操做
2024-07-18 10:17:59 阅读次数:28
python,编程开发
列表的使用
定义
# 定义空列表
变量名 = []
变量名 = list()
# 定义有默认值的列表
变量名 = [数据1,数据n]
增
列表.append(数据)

删
按值删除
列表.remove(数据)

按索引删除
删除的数据 = 列表.pop(索引值)

改
列表[索引] = 值

查
取值操做
列表[下标]

查询内容的索引
查询数据在列表中的索引位置
下标 = 列表.index(数据)
数据不存在就会报错

元组 查操作

版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/u_13137233/3411512,作者:ifubing,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。
上一篇:Python实时检测文件及文件夹变动
下一篇:python-演练-输出一个等腰三角形-