王吉元-NWPU

导航

 
shopList=['apple','orange','pen']
print(shopList)
print('First thing is: '+shopList[0])
print('The last2 thing is: '+shopList[-2])

print('the 1 to 2 thing is: '+str(shopList[1:2]))
print('the 0 to 2 thing is: '+str(shopList[:2]))

运行结果:

['apple', 'orange', 'pen']
First thing is: apple
The last2 thing is: orange
the 1 to 2 thing is: ['orange']
the 0 to 2 thing is: ['apple', 'orange']

 

posted on 2013-12-03 17:36  王吉元  阅读(133)  评论(0编辑  收藏  举报