[Tutor] Retain UTF-8 Character in Python List

Boy Sandy Gladies Arriezona reno.esper at gmail.com
Mon Jun 1 04:39:03 CEST 2015


Hi, it's my first time in here. I hope you don't mind if I straight to the
question.
I do some work in python 2 and my job is to collect some query and then
send it to java program via json. We're doing batch update in Apache
Phoenix, that's why I collect those query beforehand.

My question is:
*Can we retain utf-8 character in list without changing its form into \xXX
or \u00XX?* The reason is because that java program insert it directly "as
is" without iterating the list. So, my query will be the same as we print
the list directly.

Example:
c = 'sffs © fafd'
l = list()

l.append(c)

print l
['sffs \xc2\xa9 fafd']  # this will be inserted, not ['sffs © fafd']


---
Best regards,
Boy Sandy Gladies Arriezona


More information about the Tutor mailing list