using_list.py
来自「《python编程金典》书中」· Python 代码 · 共 20 行
PY
20 行
#!/usr/bin/python
#filename:using_list.py
#this is my shopping list
shoplist=['apple','mango','carrot','banana']
print 'i have',len(shoplist),'item to purchase'
print 'these items are:'
for item in shoplist:
print item,
print '\n I have to buy rice.'
shoplist.append('rice')
print 'my shoping 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 bought the',olditem
print 'my shopping list now',shoplist
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?