Boy Sandy Gladies Arriezona wrote: > Hi, it's my first time in here.
Welcome! > 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'] >>> import json >>> items = [u"sffs © fafd"] # unicode preferrable over str for non-ascii data >>> print json.dumps(items, ensure_ascii=False) ["sffs © fafd"] _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor