NumPy Generate Random Integers: Quick Guide
You can generate random integers using the numpy.random.randint() function.
Example code:
import numpy as np
# 生成一个1到10之间的随机整数
random_int = np.random.randint(1, 11)
print(random_int)
# 生成一个包含10个1到100之间的随机整数的数组
random_int_array = np.random.randint(1, 101, size=10)
print(random_int_array)
Output:
6
[35 13 5 73 33 52 4 78 62 81]