Talking is cheap show me the
~picture~
list2 = [5,6,7,8,9]
print(list2[:])
# 打印出[5,6,7,8,9]
print(list2[2:])
# 打印出[7,8,9]
print(list2[:2])
# 打印出[5,6]
print(list2[1:3])
#打印出[6,7]
print(list2[2:4])
#打印出[7,8]
#口诀:
#冒号左边空,就要从偏移量为0的元素开始取;右边空,就要取到列表的最后一个元素。
#冒号左边数字对应的元素要拿,右边的不动
#[1:3]=>[1,3) #索引从0开始 [5,6,7,8,9] 就是6,7
#[2:4]=>[2,4) #索引从0开始 [5,6,7,8,9] 就是7,8
#[:2] #取:前两位 冒号在左边 左取右不取