开发者

Python: '\\x41' to '\x41'

开发者 https://www.devze.com 2023-02-21 21:44 出处:网络
How can I convert a string like \'\\\\x41\' to an escaped string like \'\\x41\', using Pyth开发者_C百科on?>>> \'\\\\x41\'.decode(\'string_escape\')

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.

  1. If you gonna print pure '\x41', you could just

print r'\x41'

  1. And if what you want is to print the 'A' out, pls do:

print u'\x41'

0

精彩评论

暂无评论...
验证码 换一张
取 消