AttributeError: 'NoneType' object has no attribute 'encode' in python 2.7 -
for item in root.findall('./channel/item'): news = {} # iterate child elements of item child in item: # special checking 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 problem ?? how gonna solve problem?
here:
else: news[child.tag] = child.text.encode('utf8')
child.text
none
in cases. don't create dict entry in case, instance this:
elif child.text not none: news[child.tag] = child.text.encode('utf8')
Comments
Post a Comment