Numpy中random.choice函数的用法举例

random.choice( list or array函数: 在list 或者 array中取一个数。

In  [1]: np.random.choice([1,2,3,4,5]) #随机选一个数字
Out [1]: 2

In  [2]: np.random.choice([1,2,3,4,5]) #随机选一个数字
Out [2]: 4

In  [3]: np.random.choice((1,2,3,4,5)) #随机选一个数字
Out [3]: 1

In  [4]: np.random.choice((1,2,3,4,5)) #随机选一个数字
Out [4]: 3

猜你喜欢

转载自blog.csdn.net/W_weiying/article/details/82118160