UnicodeDecodeError:'ascii'编解码器无法解码位置0中的字节0xd0:序数不在范围内(128)

时间:2015-02-16 17:08:03

标签: python utf-8 encode

我有一个由print语句引起的错误:

top_users = [
    {u'first_name': u'\u0425\u0440\u0438\u0441\u0442\u044f', u'last_name': u'\u041a\u0430\u0447\u043c\u0430\u0440', u'id': 1077},
    {u'first_name': u'\u042e\u043b\u0456\u044f', u'last_name': u'\u041d\u0435\u0447\u0438\u043f\u043e\u0440\u0443\u043a', u'id': 1169},
    {u'first_name': u'\u0421\u0432\u0454\u0442\u0456\u043a', u'last_name': u'\u0422\u0438\u0445\u043e\u043d\u0447\u0443\u043a', u'id': 6186},
    {u'first_name': u'Dianka', u'last_name': u'Martyushicheva', u'id': 2450},
    {u'first_name': u'\u041e\u043b\u044c\u0433\u0430', u'last_name': u'\u0414\u043e\u0431\u0440\u043e\u0432\u043e\u043b\u044c\u0441\u043a\u0430\u044f', u'id': 2977}
]

msg = u"TOP-5 most active group members:\n"
for u in top_users:
    msg = msg + u"@id%s (%s %s)\n" % (u["id"], u["first_name"], u["last_name"])

print (msg) # Here is an error

0 个答案:

没有答案