我在 php 中有以下语句将hex字符串转换为binary.
$m=pack("H*" , "A88BE9L98990........");
我需要在另一个python程序中做同样的事情吗?
有任何想法吗 ?
干杯,
该binascii模块有binascii.unhexlify(hexstr),它可以满足您的需求。
>>> import binascii
>>> binascii.unhexlify("A88BE9L98990")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Non-hexadecimal digit found
# Not sure why there's an L in there... take it out...
>>> binascii.unhexlify("A88BE9989900")
'\xa8\x8b\xe9\x98\x99\x00'
python2php网站可以帮助你 - 它建议使用struct.pack