I am trying to convert a string to bytes keeping one backslash but it is represented as two. When I pass the following string \xe8\x5b\xfd\xff\xff\xe8\x56\xfd\xff
from outside Python, either reading a file or with argv and then I encode() it to get bytes I get b'\\xe8\\x5b\\xfd\\xff\\xff\\xe8\\x56\\xfd\\xff'
, but I would need it with only one.
Here is the code I currently have.
element = sys.argv[1]
element = element.encode()
print(element)
I have tried many different solutions such as .encode(raw_unicode_escape) to no avail. Any help would be greatly appreciated.