[Tutor] Iterating writing in a file

Bernard Lebel python at bernardlebel.com
Tue Jul 13 23:24:30 CEST 2004


Hello,

I wish to do an iteration that will write something on each new line in a
text file. Something like this:


sFile = 'C:\\myFile.txt'
oFile = file( sFile, 'rw' )

for oLine in range(1,10):
    oFile.write( 'text' )



However when I run this I get an IO error for the oFile.write() line.


Any suggestion?
Thanks
Bernard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040713/c001c05b/attachment.htm


More information about the Tutor mailing list