import numpy as np
a = np.random.rand(5)
print(a)
[0.45109132 0.63675963 0.51812938 0.38780661 0.92640207]
print(a[-1]) #打印最后一个元素
0.926402067797278
print(a[:-1]) #打印除了最后一个元素
[0.45109132 0.63675963 0.51812938 0.38780661]
print(a[::-1]) #逆序打印
[0.92640207 0.38780661 0.51812938 0.63675963 0.45109132]
print(a[2::-1]) #从下标为2的元素往前逆序打印
[0.51812938 0.63675963 0.45109132]