shopList=['apple','orange','pen']
print(shopList)
print('First thing is: '+shopList[])
print('The last2 thing is: '+shopList[-]) print('the 1 to 2 thing is: '+str(shopList[:]))
print('the 0 to 2 thing is: '+str(shopList[:]))
运行结果:
['apple', 'orange', 'pen']
First thing is: apple
The last2 thing is: orange
the to thing is: ['orange']
the to thing is: ['apple', 'orange']