# python slicing 和函数range 差不多, 起始值,最后值,步长值 a='abcdefghijklmnopqrstuvwxyz' print(a[:],end=' \n') # abcdefghijklmnopqrstuvwxyz print(a[:5], end=' \n') #abcde print(a[:-1], end=' \n') #abcdefghijklmnopqrstuvwxy print(a[4:], end=' \n') #efghijklmnopqrstuvwxyz print(a[-3:], end=' \n') #xyz print(a[2:-1], end=' \n') #cdefghijklmnopqrstuvwxy print(a[-3:-1], end=' \n') #xy print(a[12:6:-1], end=' \n') #mlkjih print(a[::-1], end=' \n') #zyxwvutsrqponmlkjihgfedcba print() a=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] print(a[:],end=' \n') # abcdefghijklmnopqrstuvwxyz print(a[:5], end=' \n') #abcde print(a[:-1], end=' \n') #abcdefghijklmnopqrstuvwxy print(a[4:], end=' \n') #efghijklmnopqrstuvwxyz print(a[-3:], end=' \n') #xyz print(a[2:-1], end=' \n') #cdefghijklmnopqrstuvwxy print(a[-3:-1], end=' \n') #xy print(a[12:6:-1], end=' \n') #mlkjih print(a[::-1], end=' \n') #zyxwvutsrqponmlkjihgfedcba
标签:abcdefghijklmnopqrstuvwxyz,end,mlkjih,Python,slicing,print,abcdefghijklmnopqrstu From: https://www.cnblogs.com/geovindu/p/18280903