Python中怎样生成一个随机序列?
代码例子如下:生成一个0-9的随机序列
1 >>> from numpy.random import normal,random,uniform; 2 >>> import numpy as np; 3 >>> random.permutation(range(10)) 4 Traceback (most recent call last): 5 File "<pyshell#2>", line 1, in <module> 6 random.permutation(range(10)) 7 AttributeError: ‘builtin_function_or_method‘ object has no attribute ‘permutation‘ 8 >>> np.random.permutation(range(10)) 9 array([9, 3, 1, 8, 7, 6, 2, 0, 5, 4])
时间: 2024-10-24 07:31:20