Feedparser停止工作
昨天我在我的Mac电脑上安装了feedparser,运行得很好,但现在它突然不工作了。
这是我用的脚本(从feedparser的说明文档上复制的)
import feedparser
d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
d['feed']['title']
u'Sample Feed'
它给我提示了这个错误:
Traceback (most recent call last):
File "example.py", line 3, in <module>
import feedparser
File "example.py", line 2, in <module>
d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
AttributeError: 'module' object has no attribute 'parse'
而且我用feedparser写的一个实际脚本也不工作了,出现了同样的错误。
2 个回答
0
问题出在文件的名字上。Python会把文件名和模块名搞混淆。
10
重点是,当有一个叫做 feedparser.py 的脚本时,Python 会优先把它当作一个模块来导入,而不是去找已经安装的模块。