我希望你能为Python中的字节数组替换双反斜杠为单个反斜杠。例如,有一个字节数组:
我需要这个字节字符串。
如果我使用replace函数,例如:
word = b'Z\xa6\x97\x86j2\x08q\\r\xca\xe6m'
我需要这个字节字符串。
word = b'Z\xa6\x97\x86j2\x08q\r\xca\xe6m'
如果我使用replace函数,例如:
word = word.replace(b"\\",b"\")
我遇到了这个错误。
File "test.py", line 79
word = word.replace(b"\\", b"\")
^
SyntaxError: EOL while scanning string literal
有人知道怎么做吗?