The thing with the famous UnicodeDecodeError is that you do some string manipulation, like the one you just did:
user.record["fullname"] + u" 准备好了"
because what you are doing is joining str with unicode, so python will implicitly force str to unicode before doing concatenation, this enforcement is done as follows:
unicode(user.record["fullname"]) + u" 准备好了" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Problem
And there is a problem, because when executing unicode(something) python will decode the string using the default encoding, which is ASCII in python 2. *, and if it happens that your user.record["fullname"] string has some character not -ASCII, it will raise a known UnicodeDecodeError error.
as you can solve it:
PS: Now in python 3 the default encoding is utf-8, and one more thing you cannot concatenate unicode with a string (bytes in python 3.), so there is more implicit coercion
mouad source share