切片类似于 substring ,比 substring 好用a=[5,56,5,6,85,99,2,4,5,5,7]print (a[:-5],a[-5:],a[3:5],a[:2])输出结果:[5, 56, 5, 6, 85, 99] [2, 4, 5, 5, 7] [6, 85] [5, 56]print ("士大夫的范德萨的"[:2])
士大
python--切片
原文:https://www.cnblogs.com/hisuper/p/9803366.html