Python equivalent php package

I have this statement below in php to convert a hex string to binary .

 $m=pack("H*" , "A88BE9L98990........"); 

Do I need to do the same in another python program?

Any ideas?

Greetings

+1
source share
2 answers

The binascii module has binascii.unhexlify(hexstr) , which does what you want.

 >>> 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 an L in there... take it out... >>> binascii.unhexlify("A88BE9989900") '\xa8\x8b\xe9\x98\x99\x00' 
+5
source

python2php website can help you - suggest using struct.pack

0
source

Source: https://habr.com/ru/post/1469004/


All Articles