博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数据结构
阅读量:4680 次
发布时间:2019-06-09

本文共 701 字,大约阅读时间需要 2 分钟。

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)

吃饭去了,吗的,还是茄子排骨

转载于:https://www.cnblogs.com/sakura3/p/8370716.html

你可能感兴趣的文章