我正在使用Python 3.6并试图熟悉feedparser库。现在,当我使用此代码时:
import feedparser
d = feedparser.parse('http://feedparser.org/docs/examples/atom10.xml')
d['feed']['title']
在官方文档网站(https://pythonhosted.org/feedparser/introduction.html)上可用,我遇到了前面提到的关键错误:
Traceback (most recent call last):
File "/Users/myName/PycharmProjects/NLTK/21.11.2018.py", line 34, in <module>
print(d['feed']['title'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/feedparser.py", line 356, in __getitem__
return dict.__getitem__(self, key)
KeyError: 'title'