首页 > 代码库 > Python中生成一个0-n的随机序列

Python中生成一个0-n的随机序列

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 permutation8 >>> np.random.permutation(range(10))9 array([9, 3, 1, 8, 7, 6, 2, 0, 5, 4])                                                                                                              

Python中生成一个0-n的随机序列