File write/read question

Alex Martelli aleax at aleax.it
Mon May 13 13:12:33 EDT 2002


Nathan Hellmers wrote:
        ...
> that an integer written to a file is actually a string, but how do I
> convert the string to an integer once I have read it with program #2?
        ...
> a = test2.readline()
> int(a)

Just change this latter, isolated, useless expression statement into
a rebinding of a:

a = int(a)

and there you are.


Alex




More information about the Python-list mailing list