Writing some floats in a file in an efficient way

ast none at gmail.com
Wed Feb 21 10:59:30 EST 2018


Le 21/02/2018 à 14:27, ast a écrit :

struct.pack() as advised works fine.
Exemple:

 >>> import struct
 >>> struct.pack(">d", -0.0)
b'\x80\x00\x00\x00\x00\x00\x00\x00'

before I read your answers I found a way
with pickle

 >>> import pickle
 >>> pickle.dumps(-0.0)[3:-1]
b'\x80\x00\x00\x00\x00\x00\x00\x00'

but struct.pack() is better
Thx





More information about the Python-list mailing list