What is the easiest way of converting a ASCII-String into hex without changing the value?
what i have:
string = "00FA0086"
what i want:
hex_string = b'\x00\xFA\x00\x86"
Is there a simple way or do i need to write a function?
What is the easiest way of converting a ASCII-String into hex without changing the value?
what i have:
string = "00FA0086"
what i want:
hex_string = b'\x00\xFA\x00\x86"
Is there a simple way or do i need to write a function?
You are looking for the binascii
module from the Standard Python Library:
import binascii
string = "00FA0086"
print(repr(binascii.a2b_hex(string)))
gives:
b'\x00\xfa\x00\x86'