Determining the Number of Lines in a File : Readlines : File PYTHON TUTORIALS


PYTHON TUTORIALS » File » Readlines »

 

Determining the Number of Lines in a File


filePath = "input.txt"

lineCount = len(open(filePath, 'rU').readlines())
print "File %s has %d lines." (filePath,lineCount)



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo File
» Readlines