为什么 numpy 随机重新洗牌不适用于 numpy 数组?

Why doesn't numpy random reshuffle work on a numpy array?

这是我的示例代码:

ah = np.linspace(1, 20, 20)
print(ah)
>>> [  1.   2.   3.   4.   5.   6.   7.   8.   9.  10.  11.  12.  13.  14.  15.
      16.  17.  18.  19.  20.]

print(np.random.shuffle(ah))
>>> None

According to the docs,输入应为数组或列表。为什么上面的示例代码不起作用?

重新洗牌到位,重新洗牌功能没有return任何东西:

测试代码:

ah = np.linspace(1, 20, 20)
print(ah)
print(np.random.shuffle(ah))
print(ah)

结果:

[  1.   2.   3.   4.   5.   6.   7.   8.   9.  10.  11.  12.  13.  14.  15.
  16.  17.  18.  19.  20.]

None

[  5.  15.  13.   8.   1.   2.  18.   7.  14.   4.  10.   6.  17.  11.  16.
  19.  12.   3.  20.   9.]