用python轉換浮點數為16進制怎么寫?
# -*- coding: utf8 -*-import ctypesdef h2f(s): cp = ctypes.pointer(ctypes.c_longlong(s)
) fp = ctypes.cast(cp, ctypes.POINTER(ctypes.c_double)
) return fp.contents.valuedef f2h(s): fp = ctypes.pointer(ctypes.c_double(s)
) cp = ctypes.cast(fp, ctypes.POINTER(ctypes.c_longlong)
) return hex(cp.contents.value)print(f2h(34.4536)
)print(h2f(0x40413a0f9096bb99))