[英]How do I convert hexadecimal string to text
如何在 Python 中将十六进制字符串转换为文本?
我有一个十六进制字符串
0x3C503E3235206D4C206F662033204D2048436C207765726520616464656420746F203735206D4C206F6620302E3035204D2048436C2E20546865206D6F6C6172697479206F662048436C20696E2074686520726573756C74696E6720736F6C7574696F6E20202026656D73703B26656D73703B26656D73703B26656D73703B2020200D0A20202026656D73703B26656D73703B26656D73703B26656D73703B2020697320617070726F78696D6174656C792D
我想在 Python 的帮助下将其转换为文本。 我该怎么做?
我试过这个
print(bytes.fromhex(xyz))
其中xyz
是存储此字符串的变量,但出现此错误
在 position 1 处的 fromhex() arg 中找到非十六进制数
只需从字符串的开头切出'0x'
字符即可。 所以
print(bytes.fromhex(var[2:]))
会给
b'<P>25 mL of 3 M HCl were added to 75 mL of 0.05 M HCl. The molarity of HCl in the resulting solution      \r\n      is approximately-'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.