Python unicode conversion

83 views Asked by At

I have the following unicode: s = u'\\u5b50'. I want to convert s to m = u'\u5b50'. How do I do it?

s = u'\\u5b50'
m = u'\u5b50'
print len(s) # 6
print len(m) # 1
print s # \u5b50
print m # 子
1

There are 1 answers

1
Transcendental On BEST ANSWER

This works:

print s.decode('unicode-escape') # 子
print len(s.decode('unicode-escape')) # 1