Str = """\\x3Cstyle\\x3E\\x0A\\x20\\x20\\x20.mainDiv\\x0A\\x20\\x20\\x7B\\x0A\\x20\\x20width\\x3A1000px\\x3B\\x0A\\x20\\x20background\\x2Dimage\\x3Aurl"""
我需要输出为:
<style\>
.mainDiv
{
width\:1000px;
background-image:URL
}
我需要使用 Python 对其进行解码
Str = """\\x3Cstyle\\x3E\\x0A\\x20\\x20\\x20.mainDiv\\x0A\\x20\\x20\\x7B\\x0A\\x20\\x20width\\x3A1000px\\x3B\\x0A\\x20\\x20background\\x2Dimage\\x3Aurl"""
我需要输出为:
<style\>
.mainDiv
{
width\:1000px;
background-image:URL
}
我需要使用 Python 对其进行解码
你必须'raw_unicode_escape'
使用'unicode_escape'
Str = """\\x3Cstyle\\x3E\\x0A\\x20\\x20\\x20.mainDiv\\x0A\\x20\\x20\\x7B\\x0A\\x20\\x20width\\x3A1000px\\x3B\\x0A\\x20\\x20background\\x2Dimage\\x3Aurl"""
Str = Str.encode('raw_unicode_escape').decode('unicode_escape')
print(Str)
Python 文档:编解码器Python 特定编码