我收到此错误: AttributeError: 'NoneType' object has no attribute 'append' 我试图将所有条目值存储在一个字典中,因为我创建了一个函数:
rss_url = 'https://www.espn.com/espn/rss/' + league + '/news'
parser = feedparser.parse(rss_url)
newsInfo = {
'title': None,
'link': None,
'description': None,
'image': None
}
for entry in parser.entries:
newsInfo['title'].append(entry.title)
newsInfo['link'].append(entry.links[0].href)
newsInfo['description'].append(entry.description)
newsInfo['image'].append(entry.content[0].value)
return newsInfo
但是,在我使用的行中,.append出现了 NoneType 错误。
奖励问题:如果我将来自 feedparser 的值呈现到 HTML 上,它会正确显示新闻吗,还是会有另一个步骤?
慕码人2483693
相关分类