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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -