0

I get stuck in converting a utf-8 bytes to int

code:

print(offset)
off = offset.decode('utf-8')
print(off)
off = int(off, 16)
print(off)

offset is byte array witch coded in utf-8. output of code is :

b'D\x00\x00\x00\x00\x00\x00\x00'
D
Traceback (most recent call last):
    off = int(off, 16)
ValueError: invalid literal for int() with base 16: 'D\x00\x00\x00\x00\x00\x00\x00'

How can I convert byte array like b'D\x00\x00\x00\x00\x00\x00\x00' to int ?

ali kiani
  • 867
  • 1
  • 13
  • 28

0 Answers0