操作list_code

ListSutDemo2

#coding=utf-8

l = ['fly','kill',12345,True,'世界']

print l[4] # 输出第五个元素

#print l[12] # 注意,你不能访问一个不存在的元素,比如l[10],程序就会报错,提示你index越界了。

l[0] = 'haha'   # 修改第一个元素为'haha'
print l
print

l.append('fine')    # 添加一个元素为'fine'到数组最后
print l[5]
print l
print

print l
print '查看第二个元素=',l[1]
del l[1]
print '查看新的第二个元素=',l[1]
print l

 

 

猜你喜欢

转载自jason-long.iteye.com/blog/2375749