I have a string of hex commands for a mifare reader, an example of one of the commands being
'\xE0\x03\x06\x01\x00'
This will give a response of 16 bytes, an example being:
'\x0F\x02\x02\x07\x05\x06\x07\x01\x09\x0A\x09\x0F\x03\x0D\x0E\xFF'
I need to store these values in a text document but whenever I try to make the hex commands into a string, the string always changes and doesn't keep its original format, and this string will turn into
'\x0f\x02\x02\x07\x05\x06\x07\x01\t\n\t\x0f\x03\r\x0eÿ'
I have tried to change the formatting of this, by using
d = d.encode()
print("".join("\\x{:02x}".format(c) for c in d))
# Result
'\x0f\x02\x02\x07\x05\x06\x07\x01\t\n\t\x0f\x03\r\x0eÿ'
Also by changing the encoding of the string but this also doesn't give the original string as a result after decoding. What I would like to get as a result would be
'\x0F\x02\x02\x07\x05\x06\x07\x01\x09\x0A\x09\x0F\x03\x0D\x0E\xFF'
This is so the mifare reader can use this string as data to write to a new tag if necessary. Any help would be appreciated