I've looked for ways to convert the following type of hex output to string characters in Python. The output comes from STDOUT earlier in my code and I want to be able to process it further.
Let me give you some examples of the string I want converted:
\x5f\x63\x6c\x6f\x73\x65\x28
I want this type of string to be stripped of '\x' and I am only interested in the two hex characters that follow. Preferably, I would like to convert strings like this into;
5f 63 6c 6f 73 65 28
The original input is interpreted as a string, but I am not able to simply strip the \x in Python itself. It would be great if I can solve this conversion internally within Python?
>>> '\x12\x34\x56\x78'.encode('hex')
'12345678'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With