
-
numpy模块:numpy.random.randint(low[, high, size]) 返回随机的整数,位于半开区间 [low, high)。
1
2import numpy as np
relist = np.random.randint(10,size=10) -
numpy模块:numpy.random.permutation(x)返回随机序列
1
2import numpy as np
relist = list(np.random.permutation(10))
-
使用random返回随机序列
-
正常写法:
1
relist = [random.randint(x, 100) for x in range(10)]
-
二逼写法:
1
relist = list(map(lambda x: random.randint(x, 100), [x for x in range(10)]))
-




近期评论