学习网址
import numpy as npresult=np.random.choice([1,4,6,8],4)
print(result)
实验结果:
"C:\Program Files\Anaconda3\python.exe" D:/pycharmprogram/tensorflow_learn/rnn_learn/np_random_choice_learn.py
[4 6 6 6]Process finished with exit code 0
在[1,4,6,8]中随机采样4次生成结果[4 6 6 6]
如果第一个参数是5,然后表示range(5)=[0,1,2,3,4]