Skip to main content
 首页 » 编程设计

python之Feedparser 停止工作

2025年05月04日13tuyile006

昨天我安装了 feedparser(在 OSX 10.5 上)并且运行良好,但现在它停止工作了。

这是脚本(从 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 的实际脚本也停止工作,同样的错误。

请您参考如下方法:

关键是当有一个名为 feedparser.py 的脚本时,python 会将其视为一个模块,以比安装的模块更高的优先级导入。