切片类似于 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])
士大
本文共 232 字,大约阅读时间需要 1 分钟。
切片类似于 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])
士大
转载于:https://www.cnblogs.com/hisuper/p/9803366.html