python:module没有属性mechanize

时间:2010-11-21 03:58:21

标签: python attributes module mechanize-python

#!/usr/bin/env python
import mechanize

mech = mechanize.Browser()
page = br.open(SchoolRank('KY'))

给予:

Traceback (most recent call last):
  File "mechanize.py", line 2, in <module>
    import mechanize
  File "/home/jcress/Documents/programming/schooldig/trunk/mechanize.py", line 12, in <module>
    mech = mechanize.Browser()
AttributeError: 'module' object has no attribute 'Browser'

我很困惑。我为2.6和2.7安装了模块,结果相同......

1 个答案:

答案 0 :(得分:18)

更改您的文件名远离mechanize.py。 Python正在将您的文件导入为模块。