How do I convert between a hanzi character and it’s unicode value as depicted below?
与toU+4E0E今toU+4ECA令toU+4EE4免toU+514D
Appears unsupported by default:
>>> a = '安'
Unsupported characters in input
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.
The small ‘u’ in front of the quote indicates that a Unicode string is supposed to be created.
See the the string documentation for more information: http://docs.python.org/tutorial/introduction.html#unicode-strings
Update:
Set the source file encoding according to the actual encoding of the file, so that the interpreter knows how to parse it.
For example, to use UTF-8 just add this string to the header of the file: