list
是处理一组有序项目的数据结构,即你可以在一个列表中存储一个 序列 的项目
顾名思义,英语就是列表清单的意思。它是一个可变的数据类型。你可以对它进行操作,添加,搜索,删除。
对list 的简单操作。打印删除,追加。切片这个没说简易教程。看完这个去看廖雪峰的。
shoplist = [‘apple‘,‘mango‘,‘carrot‘,‘banana‘] print (‘i have‘,len(shoplist),‘items to purchase‘) print (‘these items are:‘) for item in shoplist: print(item), print(‘\ni also have to buy rice.‘) shoplist.append(‘rice‘) print(‘my shopping list is now‘,shoplist) print(‘i will sort my list now‘) shoplist.sort() print(‘sorted shopping list is‘,shoplist) print(‘the first item i will buy is‘,shoplist[0]) olditem = shoplist[0] del shoplist[0] print(‘i bougth the‘,olditem) print (‘my shopping list is now‘,shoplist)
吃饭去了,吗的,还是茄子排骨