My previous message just went up -- sorry for the mangled formatting. Here it is properly formatted:
I want to write a list of 64-bit integers to a binary file. Every example I have seen in my research converts it to .txt, but I want it in binary. I wrote this code, based on some earlier work I have done:
buf = bytes((len(qs_array)) * 8)
for offset in range(len(qs_array)):
item_to_write = bytes(qs_array[offset])
struct.pack_into(buf, "<Q", offset, item_to_write)
But I get the error "struct.error: embedded null character."
Maybe there's a better way to do this?
Any help will be very appreciated.
--
https://mail.python.org/mailman/listinfo/python-list
I want to write a list of 64-bit integers to a binary file. Every example I have seen in my research converts it to .txt, but I want it in binary. I wrote this code, based on some earlier work I have done:
buf = bytes((len(qs_array)) * 8)
for offset in range(len(qs_array)):
item_to_write = bytes(qs_array[offset])
struct.pack_into(buf, "<Q", offset, item_to_write)
But I get the error "struct.error: embedded null character."
Maybe there's a better way to do this?
Any help will be very appreciated.
--
https://mail.python.org/mailman/listinfo/python-list