如何在Python中将十六进制字符串转换为文本?
我有一个十六进制字符串
3C503E3235200E3235200E32033204D20404204204204204204204204204204204204204204204204242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424216767676767676767676767676767676767676767676767676767676767676767676767676767676767676767676767676767666624242424242424242424242424242424242424242424242424242424242012012012012012012012012012012012012012012012012012012016656D73703B26656D73703B26656D73703B2020693206170726F78696D6174656C792D型
我想在Python的帮助下把它转换成文本。我该怎么做?
我试过了
print(bytes.fromhex(xyz))
其中
xyz
是存储此字符串的变量,但出现此错误在位置1的fromhex()参数中找到非十六进制数
最佳答案
只需从字符串的开头切掉“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-'
关于python - 如何在Python中将十六进制字符串转换为文本,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58834748/