python UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2: ordinal not in range(128)错误解决办法

import sys

 

reload( sys )
sys.setdefaultencoding('utf-8')

 

 

在需要print的地方,前面加上u

print u'%-18s %-12s %s' % (truncate(entry.title.text.encode('UTF-8')),
                                entry.GetDocumentType(),
                                entry.resourceId.text)

posted @ 2011-10-11 16:38  keepfocus  阅读(5311)  评论(0编辑  收藏  举报