代码
import numpy as np
# 修改numpy打印设置
np.set_printoptions(linewidth=1024)
# 指定seed
m_seed = 20
# 设置seed
np.random.seed(m_seed)
# 测试(随机抽样,抽6个,范围是在[0,40000)的整数)
print(np.random.randint(40000, size=6))
print(np.random.randint(40000, size=6))
print(np.random.randint(40000, size=6))
print(np.random.randint(40000, size=6))
print(np.random.randint(40000, size=6))
print(np.random.randint(40000, size=6))
执行第1次,输出
[27098 37135 23775 23452 31962 3915]
[22294 1607 15328 8744 21973 33242]
[26394 11003 34576 36582 31462 5264]
[ 4713 28517 29447 12773 39906 20427]
[26554 28185 9930 22731 34643 36718]
[ 6432 15114 3915 22013 23501 43]
执行第2次,输出
[27098 37135 23775 23452 31962 3915]
[22294 1607 15328 8744 21973 33242]
[26394 11003 34576 36582 31462 5264]
[ 4713 28517 29447 12773 39906 20427]
[26554 28185 9930 22731 34643 36718]
[ 6432 15114 3915 22013 23501 43]