标签:元祖 col 打印 bsp span 有序 反向 常用 增加
list1 = [‘ji‘,‘yan‘,‘jiao‘] list2 = list1[:] print(‘list1[:] 打印出的结果为:‘,list2) ‘‘‘ 打印结果: list1[:] 打印出的结果为: [‘ji‘, ‘yan‘, ‘jiao‘] ‘‘‘ list1 = [‘ji‘,‘yan‘,‘jiao‘] list3 = list1[0:1:1] list3_1 = list1[0:2:1] list3_2 = list1[0:2:2] list3_2_1 = list1[0:3:2] list3_3 = list1[0:-1:1] print(‘list1[0:1:1] 打印的结果为:‘,list3) print(‘list1[0:2:1] 打印的结果为:‘,list3_1) print(‘list1[0:2:2] 打印的结果为:‘,list3_2) print(‘list1[0:3:2] 打印的结果为:‘,list3_2_1) print(‘list1[0:-1:1] 打印的结果为:‘,list3_3) ‘‘‘ 打印结果: list1[0:1:1] 打印的结果为: [‘ji‘] list1[0:2:1] 打印的结果为: [‘ji‘, ‘yan‘] list1[0:2:2] 打印的结果为: [‘ji‘] list1[0:3:2] 打印的结果为: [‘ji‘, ‘jiao‘] list1[0:-1:1] 打印的结果为: [‘ji‘, ‘yan‘] ‘‘‘ list1 = [‘ji‘,‘yan‘,‘jiao‘] list4 = list1[:2] list4_1 = list1[:3] print(‘ list1[:2]打印结果为:‘,list4) print(‘ list1[:3]打印结果为:‘,list4_1) ‘‘‘ 打印结果: list1[:2]打印结果为: [‘ji‘, ‘yan‘] list1[:3]打印结果为: [‘ji‘, ‘yan‘, ‘jiao‘] ‘‘‘ list1 = [‘ji‘,‘yan‘,‘jiao‘] list5 = list1[2:0:-1] list5_1 = list1[2:0:-2] print(‘ list1[2:0:-1]打印结果为:‘,list5) print(‘ list1[2:0:-2]打印结果为:‘,list5_1) ‘‘‘ 打印结果: list1[2:0:-1]打印结果为: [‘jiao‘, ‘yan‘] list1[2:0:-2]打印结果为: [‘jiao‘] ‘‘‘
标签:元祖 col 打印 bsp span 有序 反向 常用 增加
原文地址:https://www.cnblogs.com/jiyanjiao-702521/p/9322605.html