I want to convert "0d" to 0xd or "ff" to 0xff.
I have tried hex("0d")
I want to convert "0d" to 0xd or "ff" to 0xff.
I have tried hex("0d")
Do base conversion as 16, the second operand to int takes the base value of the number you need to convert
>>> a = "0d"
>>> int(a,16)
13
>>> hex(int(a,16))
'0xd'
>>> a = "ff"
>>> int(a,16)
255
>>> hex(int(a,16))
'0xff'