0
for item in root.findall('./channel/item'):
news = {}
# iterate child elements of item
for child in item:
# special checking for namespace object content:media
if child.tag == '{http://search.yahoo.com/mrss/}content':
news['media'] = child.attrib['url']
else:
news[child.tag] = child.text.encode('utf8')
newsitems.append(news)
whats問題?どのように私はこの問題を解決するつもりですか?ここAttributeError: 'NoneType'オブジェクトには、Pythonで 'エンコード'属性がありません2.7
これは 'child.text'が' None'であるためです。それをフィルタリングしてください。 'if child.text:... ' –