Say I have someString = "00"
. basically I want to convert someString
to \x00
I tried multiple ways to achieve my goal, but couldn't find a successful one.
tried:
HexString = '\x'+someString
This method throws this error:
ValueError: invalid \x escape
Unless I do HexString = r'\x'+someString
, but then HexString
value is set to \\x00
which is not the same as I want.
I also tried using hex()
function, which had few issues. But the big issue I had with it was that it returns 0x0
. It expects int
and etc...
Can anyone help me with converting a string("11"
) to \x11
?