[英]Python: How to convert a hexadecimal string to a normal string?
I have a string of the following form我有以下形式的字符串
\xNN\xNN\xNN\xNN… \xNN\xNN\xNN\xNN…
str = "\x41\x42\x43"
Is there a simple way to convert this type of string to a normal string?有没有一种简单的方法可以将这种类型的字符串转换为普通字符串? For example "\x41\x42\x43" is equivalent to "ABC".例如“\x41\x42\x43”等价于“ABC”。
How about怎么样
>>> s = b"\x41\x42\x43"
>>> print(s)
b'ABC'
Or或者
>>> s = "\x41\x42\x43"
>>> print(s.encode())
b'ABC'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.