How to write integers to a file?

Jim Richardson warlock at eskimo.com
Sat Feb 10 03:50:34 EST 2001


On Fri, 09 Feb 2001 13:06:36 GMT, 
 Steven Sartorius, in the persona of <ssartor at bellatlantic.net>,
 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...
>
>Thanks,
>
>Steve Sartorius

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

-- 
Jim Richardson
	Anarchist, pagan and proud of it
WWW.eskimo.com/~warlock
	Linux, because life's too short for a buggy OS.




More information about the Python-list mailing list