Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert my byte data to integer using python?

I have a byte data is like: b'\xc4\x03\x00\x00\xe2\xecqv\x01'.
How do I convert this to integer like index by index.

like image 581
user3615194 Avatar asked Feb 28 '26 07:02

user3615194


1 Answers

a bytes object is basically already a (immutable) sequence of integers.

b = b'\xc4\x03\x00\x00\xe2\xecqv\x01'
b[0] # 196
lst = list(b)
#  [196, 3, 0, 0, 226, 236, 113, 118, 1]
like image 121
hiro protagonist Avatar answered Mar 01 '26 20:03

hiro protagonist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!