Help to convert Number to String

Vamsi vamsikrishna.bandlamudi at gmail.com
Fri Aug 13 16:50:48 EDT 2010


I am trying to count the number of lines in a file and insert  into
the file but getting the error message "TypeError: must be string or
read-only character buffer, not int", Could you please help me how to
correct this?


here is the code

lines1 = sum(1 for line in open('C:/test1.txt'))
wfile = open('C:/test1.txt'', 'a')
wfile.write(str(lines1).zfill(9))
wfile.close()

Thanks.



More information about the Python-list mailing list