I need the a string to be converted to bytes exactly as it is, so it would look like b and binascii.hexlify() would be the same for both a and b. Best way to do it? Python 3.10.0
a = "\x8e"
b = b'\x8e'
print(bytes(a, 'utf-8')) # b'\xc2\x8e'
print(b) # b'\x8e'
print(binascii.hexlify(bytes(a, 'utf-8'))) # b'c28e'
print(binascii.hexlify(b)) # b'8e'