欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

用python轉換浮點數為16進制怎么寫

洪振霞2年前11瀏覽0評論

用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))