code
a = "한글" #korean language
a_list = []
a_list.append({'key': a})
print a_list
result
[{'key': u'"\ud55c\uae00"'}]
I don’t want to convert unicode.
How can I stay in korean language
I wish to print like this
[{'key': '한글'}]
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.
Your code from the question produces:
This output is different from what you have shown in the question.
To produce:
[{"key": "한글"}]you could usejson:Full example
Output
You wrote:
Read The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!).
The main takeaway is if you are working with text you must specify its encoding.
The most convenient and reliable way is to use Unicode strings throughout your program i.e., decode bytes that you read to Unicode strings as early as possible on input and encode to bytes while writing Unicode strings as late as possible on output.
To enforce that convention all strings are Unicode in Python 3. Python 2 unfortunately allows you to use bytestrings for both text and data with all confusion that it causes.