2013-11-26 93 views
1

下面是摘录:生成蟒蛇随机整数失败使用随机库

C:\APPS>python 
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win 
32 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import random 
>>> random.seed() 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
AttributeError: 'module' object has no attribute 'seed' 
>>> random.randint(0,3) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
AttributeError: 'module' object has no attribute 'randint' 
>>> 
+0

你有任何其他模块名称为“random”吗? – soon

+0

我试过了,但没有任何错误。 –

回答

3

你可能有一个文件名为在APPS目录random.py。删除或重命名该文件。

2

尝试这样的事情就看你正在使用的随机模块:

In [1]: import random 

In [2]: print(random.__file__) 
/usr/lib/python3.2/random.py 
-1

对我来说,发生这种情况,因为该文件没有保存在本地的我的电脑上,而是在基于云的文件夹。我只需在本地保存并修复它,对于任何未来有问题的人。

+0

这似乎不太可能/不相关,因为原始作者没有提及下载某个文件。 –