Skip to content

切片相关

python
a = [1, 2, 3, 4, 5]

print(a[-2:])    # [4, 5]
print(a[-10:])   # [1, 2, 3, 4, 5]
print(a[:10])    # [1, 2, 3, 4, 5]

Released under the MIT License.