1

我想在 \xNN 中打印出十六进制字符串。有什么快速的方法可以让 \xNN 转换回十六进制字符串吗?我更喜欢本机快速方法而不是手动编写长函数。

例如。

$ python
>>> '\x74op'
>>> 'top'

>>> s=r'\x74op'
>>> '\\x74op'

>>> convert(s)  # how to write this function
>>> 'top'
4

1 回答 1

5

我想你想要s.decode('string_escape')

于 2013-03-22T02:36:41.547 回答