str_test = '0x12345678' str_int = int(str_test,16) hex_int = hex(str_int) print(hex_int ) >> 0x12345678