Python: '\\x41' to '\x41'
How can I convert a string like '\\x41'
to an escaped string like '\x41'
, using Pyth开发者_C百科on?
>>> '\\x41'.decode('string_escape')
'A'
Gory details here.
I don't really understand your question, but I'll try to give you some solutions.
- If you gonna print pure '\x41', you could just
print r'\x41'
- And if what you want is to print the 'A' out, pls do:
print u'\x41'
精彩评论