How to output (write) a list of floats to a binary file in Python

1 Answer

0 votes
from array import array

fh = open('d:\data.bin', 'wb')
float_array = array('d', [1.76, 3.13, -8.6, 0.0, 1.1])

float_array.tofile(fh)

fh.close()


'''
run:

data.bin
--------
)\ֲץ(?
׳£p=
	@333333!ְ        š™™™™™ס?

'''

 



answered Dec 22, 2017 by avibootz

Related questions

1 answer 184 views
1 answer 238 views
1 answer 193 views
1 answer 176 views
1 answer 241 views
...