writing numbers in binary file
eskandari
razieh.eskandari at gmail.com
Mon May 31 11:56:23 EDT 2010
Hi,
I am a newbie in python. I have an data.pickle file which is
serialized form of an "array of strings", I want to write their
offsets in another binary file, so an C++ program can read and analyse
them.
But when I try to write offset (number) in binary file, it raise
exception below in line "offsetfile.write(offset)"
"TypeError: argument 1 must be string or read-only buffer, not int"
I search the internet, find that all suggest converting number to
string ---with str()---and then write string to file.
But I shouldn't do this. because the above mentioned C++ function,
read file with this assumption that there are numbers in file.
So I want to know, Is there any way to produce an binary file
containing numbers same as the way C++ does?
Can anybody help me?
Thanks a lot.
More information about the Python-list
mailing list