Reputation: 27221
I've got
u'≈'.encode('unicode_escape')
I want to receive "\u2248" as string.
Upvotes: 2
Views: 137
Reputation: 41510
I think I've figured out a way to do that. You can do .decode('ascii')
right on the string, then it will give you back the encoded string, for example:
"🙂".encode("unicode_escape").decode('ascii')
gives you
'\\U0001f642'
Upvotes: 2