import struct def float_to_hex(f): b = struct.pack(">f", f) return b.hex()