How to write integers to a file?

Jim Richardson warlock at
Sat Feb 10 09:50:34 CET 2001

On Fri, 09 Feb 2001 13:06:36 GMT, 
 Steven Sartorius, in the persona of <ssartor at>,
 brought forth the following words...:

>I'm trying to write a series of whitespace delimited integers to a file.
>The 'write' method only accepts strings and using arrays produces binary
>data when I open the file with less.  What I want is somehting like
>printf for python.  Is there any easy way to do this?  (there must
>be...this is python!)
>Any help much appreciated...
>Steve Sartorius

use str(integer) to convert to a string before the write.

Jim Richardson
	Anarchist, pagan and proud of it
	Linux, because life's too short for a buggy OS.

More information about the Python-list mailing list