2011-12-15 10 views
0

random.randint()を呼び出すと、次のエラーが発生します。誰も何が起こっているか説明できますか?ランダムモジュールにrandint()関数がありません

$ python 
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import random 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "random.py", line 4, in <module> 
    print >>file,random.randint(100,10000) 
AttributeError: 'module' object has no attribute 'randint' 
>>> random.randint(100) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
NameError: name 'random' is not defined 

答えて

13

あなたはスクリプト「random.py」を呼び出しました。同じ名前のstdlibモジュールをシャドーイングしないように名前を変更します。

関連する問題