Simple File I/O Question

Curtis Jensen cjensen at bioeng.ucsd.edu
Thu Jul 13 12:41:30 EDT 2000


I know this should be simple, but....  I have a variable that holds an
int.  I want to write it to a file.  The following code:

var = 5
f = open('foo','w')
f.write(var)

gives this error:
TypeError: read-only buffer, int

This works if:
var = '5'

So, How do I write an int variable to a file?  Thanks.

-- 
Curtis Jensen
cjensen at bioeng.ucsd.edu
http://www-bioeng.ucsd.edu/~cjensen/
FAX (425) 740-1451



More information about the Python-list mailing list