I want to take an integer, that will be between 0 and 255, convert that to a hex string eg. '\xff' and then cast that to bytes to end up with b'\xff'. I had assumed that the following would work.
data_num = 255
data = chr(data_num)
data_byte = data.encode()
Any help would be appreciated