0
print(bytes(97).decode('utf8'))

This line is part of my project and its giving me a headache for a while now, If I run this the Output is just an empty space, no Error or anything else. The 97 came from encoding the 'a' with utf8. I want do work with the encoded numbers so I changed them to Integers, but I cant get them to decode once I'm done working with them

Davenport
  • 3
  • 2
  • 2
    Possible duplicate of [Converting int to bytes in Python 3](https://stackoverflow.com/questions/21017698/converting-int-to-bytes-in-python-3) – Carlos Gonzalez Mar 12 '19 at 09:38

1 Answers1

0

So if you run bytes(97) the output is b'\x00\x00\x00\x00\... but if you run bytes([97]) you get b'a' which I assume is what you expected.

EDIT:

I just found this question which explains the why:

Converting int to bytes in Python 3

Carlos Gonzalez
  • 858
  • 13
  • 23