Printing/writing an integer to a file

PS mytempmailid at gmail.com
Thu Nov 16 20:33:59 EST 2006


Friends,

I am new to python and did search on the web on how to achieve this:
( I am trying to append the line numbers to all the lines of a file for now)

Thanks!!

=================================================
import os, sys

fileName = os.path.join("C:", "temp", "x1.txt")
fileobject = open(fileName, 'r')
outputDir = "C://temp//"
linenumber = 0
fileName1 = outputDir + "x2.txt"
fileobject1 = open(fileName1, 'w')
while (1):
    L = fileobject.readline()
    if L=="":
        print "**Done"
        break
    linenumber += 1
    fileobject1.write(ln)
    fileobject1.write(":: "+ L)

fileobject1.close()
=============================================================

-- 
Regards,
Prem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061116/26459ff1/attachment.html>


More information about the Python-list mailing list