将 Python 中的十六进制字符转换为 ASCII 字符

Coverting Hex to ASCII Characters in Python

我想要这样的东西:

Kì°k[7ì]ÿ¯G]ìw/uëGU—kÔÍj+³¯Mè1Sjwˆ½öm�Á|Uç

但是我在使用时却不断收到这个 binascii.unhexlify(ph) #ph 是 Hex_string:

x05\x00\x00\xd0\x05\x00data!W\x00\x00\t\x00\x00\

PS:我基本上是想通过从我制作的包含十六进制值的字符串中删除一些代码行,将 AUDIO 文件转换为另一个扩展名。 (我用 Hex Editor 手动尝试了它,它工作得很好,我想为它制作一个 python 脚本,但我在转换步骤中发现了一个障碍)

Here is an example of what i want to get.

如果有人有同样的问题,我会找出答案。假设我想将 ch="E4BC716838B15CE6FCD5" 十六进制字符串转换为 ASCII,而 ph 是我想要获取的 ascii 字符串: 只需一次循环两个字符的字符串,对这两个字符串使用 int() 以及 16,然后使用 chr() 将数字转换为字符。 这是代码:

ch="E4BC716838B15CE6FCD5"
ph=''
for i in range(1,(len(ch)//2)+1):
   Lh=''                 
   Lh=ch[2*i-2:2*i]              #This is the two char string for each loop
   x = int(Lh,16)                #The value of the 'Lh' Hex
   ph=ph+chr(x)                  #chr is used to convert the int to ascii

结果是ph='ä¼qh8±\æüÕ'