I've experimented with the Python module named array
a bit. It has got a way to encode arrays to strings.
>>>from array import array
>>>a=[1,2,3]
>>>a=array('B',a)
>>>print(a)
array('B',[1,2,3])
>>>print(a.tostring())
b'\x01\x02\x03'
>>>str(a.tostring())
"b'\x01\x02\x03'"
I want to save the .tostring()
version of the array into a file, but the open().write()
only accepts strings.
Is there a way to decode this string to a byte-array?
I want to use it for OpenGL arrays (glBufferData
accepts the byte-arrays)
Thanks in advance.