I have a string of bytes like this:
mystring = '000102'
And I need:
result = b'\x00\x01\x02'
Now I did:
# Opt 1
result = bytearray(mystring, 'utf-8') # I suppose is not correct encoded
# Opt 2
result = mystring.encode()
And both give me, b'000102'
. How can I obtain the '\x'
that defines every byte?
Thank you very much, I suposes is an easy question, but I can't find how do it