How to convert with Python an odd number of hex digits to bytes without losing its leading zeros?
For example, string ‘0001000’ should be converted to bytes 0001000
You can use str.encode
s = '0001000'
b = str.encode(s)
print(b) # b'0001000'
How to convert with Python an odd number of hex digits to bytes without losing its leading zeros?
For example, string ‘0001000’ should be converted to bytes 0001000
You can use str.encode
s = '0001000'
b = str.encode(s)
print(b) # b'0001000'