I have a library function that is failing because I cannot seem to properly convert an integer to a proper byte string except by using a literal. Can someone explain why I get 3 different results from 3 different ways to convert an integer to a byte string?
Using a literal, which is the only way the library call works produces this:
>>> print(b'1') b'1'
Using the builtin bytes function, which the library call rejects, is really strange:
>>> i=1 >>> print(bytes(i)) b'\x00'
Finally using the to_bytes function, which the library call also rejects, is:
>>> i=1 >>> print(i.to_bytes(1,byteorder='big')) b'\x01'
At least the value seems right. Can someone explain why only using a literal works and/or the print output is different?