import struct def foo(): struct.pack(">H", 1.0) foo()