Counting lines in a file

Published: Wednesday, Dec 26, 2007 Last modified: Thursday, Nov 14, 2024

This should do it:

print 'Line count: %s' % len(open(file).readlines())