I got some strings from the database which look like '\xe7\x8e\xa9'
.
I think it's utf-8. I can print them out by using:
print '\xe7\x8e\xa9'
玩
The things is, I need write them into another file as Chinese Character(e.g. 玩) together with other alphanumeric data.
I tried encode
, decode
but I didn't get the results I was hoping for.
Here are my attempts:
f = open('a','w')
name = u.name #.encode('utf8') # I commented it to get raw
f.write('\t$$%r$$many_other_data' % name)
f.close()
When I open the output file with vim7.4:
`$$u'\u7aef\u5e84\u7684\u9a6c\u6b47\u5c14$$many_other_data'`