加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
list.py 974 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhaobo 提交于 2023-06-07 10:24 . Initial commit
#列表 list
l1 = list ("zhaoxiaobo")
print(type(l1),l1)
l7 = [1,2,3,4,5,6]
print(99 in l7)
print(6 in l7)
#运算
l5 = [1,2,3]
l6 = ["python","go"]
print(l5 + l6)
print(l5 * 3)
#常用方法
l11 = [1,2,3]
result = l11.pop()
print("l11",result,l11)
l12 = [1,2,3]
result =l12.pop(1)
print("l12",result,l12)
l13 =[1,2,"老六",3,4,"老六",5]
l13.remove("老六")
print(l13)
l14 = [2,23,14,34,17]
l14.sort()
print(l14)
l15 = [2,4,3,6,98]
l15.sort(reverse=True)
print(l15)
l16 = ["python","r","go"]
l16.sort(key=len)
print(l16)
l17 = [2,23,14,34,17,19,10]
l17 .reverse()
print(l17)
l18 =[
[1,2,3],
[4,5,6],
[7,8,9]
]
print(l18[0][0])
l18.append([100,102,103])
print(l18)
l18[0].append(99)
print(l18)
l19 = []
for i in range(10):
if i %2 == 0:
l19.append(i)
print(l19)
l20 = []
for i in range(0,10,2):
l20.append(i)
print(l20)
l21 = [i for i in range(10) if i % 2 == 0]
print(l21)
l22 = [i for i in range(0,10,2)]
print(l22)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化