I know this should be easy, but I just can't get the syntax right for python.
My int is not converted correctly. This is the output of my 2 print statements. My output should be 9718 instead of 959918392.
9718
959918392
bytearray(b'9718') 959918392
This is my conversion. I don't understand what am I doing wrong.
print(size) print(int.from_bytes(size, byteorder='big'))
What you tried assumes the number is directly encoded as bytes. You actually want to parse it from ascii, which you can do like this:
int(b'9718'.decode('ascii'))
2.1m questions
2.1m answers
60 comments
57.0k users