python - UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 7: ordinal not in range(128) -


i guess error coming fact xml file in utf-8, python wants handle ascii? have parsed xml correctly when try print contents of xml error because there foreign unicode characters. can try fix code below? may encode unicode string ascii? thanks!!

import xml.etree.elementtree et import sys  if __name__ == '__main__':     tree = et.parse('/downloads/sample.xml')     root = tree.getroot()     a=[]      child in root.iter():         if child.tag == "author":             a.append(child.text)         if child.tag == "title":             name in a:                 print "%s\t%s" % (name, child.text)             a=[] 


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -