I'm appending the number 33 to a bytearray, which works fine but when I am converting the bytearray to a bytestring the number 33 converts to an exclamation mark (!).
Example Code below:
f_bytes = bytearray(b"\xFF\xFF")
f_bytes.append(3)
f_bytes.append(33)
f_bytes.append(12)
byte_msg = bytes(f_bytes)
print(byte_msg)
print (''.join(format(x, '02x') for x in f_bytes))
Here is the output:
b'\xff\xff\x03!\x0c'
ffff03210c
I am expecting the bytestring to look like the bytearray but it doesn't, can someone help me understand the problem?