Suppose I had a string for example:
>>> stri = "日本"
>>> res = stri
>>> res
'\xe6\x97\xa5\xe6\x9c\xac'
Now I want to convert the result in res back to the form in "日本".
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
(Assuming that you’re using Python 2.x on a UTF-8 console):
Nothing has been converted, and there is no need to convert anything back; what you’re seeing is the internal representation of the string. Try
printing it.To clarify:
If you enter the name of a Python variable in the console, the console will print the
reprof that variable. If you want to print the variable in human-readable form, useprintinstead. There is no difference in the way the variable is stored, therefore there’s nothing to convert.