python string to hex with escaped hex values -
i have string "some characters \x00\x80\x34 , other characters". how can convert regular characters hex equivalent, while converting \x00 actual 00 hex value? binascii.hexlify() considers '\', 'x', '0', '0' actual characters.
later edit: string produced function. when print it, prints "\x00".
as understanding trying convert characters not hex values hex. if gave sample input string trying convert hex.
also can convert hex values using built in encoding , decoding method. should take care of trying do. following 3 lines ran in terminal of machine, , gave output expecting. attached image show you. hope helps:
astr = "some characters \x00\x80\x34 , other characters" astr.encode("hex") astr.encode("hex").decode("hex")
Comments
Post a Comment