Python——List(1)
Python学习这里只加上例子
cast=["a",1,"b",2,"c",3,"d",4]
print len(cast)
cast.append("e")
print len(cast)
print cast
cast.extend(["f","g"])
print cast
cast.remove("a")
print cast
cast.insert(0,"z")
print cast
for i in cast:
print(i)
cnt=0 #attention the origin
while cnt<len(cast):#attention the operator ':'!!!
print(cast[cnt])
cnt = cnt+1
#python don't have the check for the check-error
#so ,the check for cast[100] will get a mistake
本文通过一个具体的Python列表操作示例,介绍了如何使用Python的基本列表方法,包括添加元素、删除元素等,并展示了如何遍历列表。这是一篇适合初学者了解Python列表基本用法的文章。
961

被折叠的 条评论
为什么被折叠?



