a = [1,2,3,4,5,6,7,8]
print (a[:])
print (a[:4])
print (a[:-1])
print (a[4:])
print (a[-3:])
print (a[2:5])
print (a[2:-1])
print (a[-3:-1])
print (a[::-1])
print (a[::2])
print (a[1::2])
print (a[::-2])
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4]
[1, 2, 3, 4, 5, 6, 7]
[5, 6, 7, 8]
[6, 7, 8]
[3, 4, 5]
[3, 4, 5, 6, 7]
[6, 7]
[8, 7, 6, 5, 4, 3, 2, 1]
[1, 3, 5, 7]
[2, 4, 6, 8]
[8, 6, 4, 2]
时间: 2024-10-12 21:03:50