开发者

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.

  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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜