python Hex或Unicode反斜杠转义恢复

1
2
3
4
audio = '"\\xe9\\xba\\xa6\\xe5\\x85\\x8b\\xe9\\xa3\\x8e (HIK 1080P Camera-Audio)"'
a1 = codecs.escape_decode(audio, 'hex-escape')[0]
a2 = a1.decode("utf-8")
print(a2)
1
"麦克风 (HIK 1080P Camera-Audio)"