随机模块没有randint()函数

use*_*879 0 python

当我打电话时random.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
Run Code Online (Sandbox Code Playgroud)

Ign*_*ams 13

你已经调用了一个脚本"random.py".重命名它,使其不会遮挡同名的stdlib模块.