Pages

Python: Line Count in Text File

Good Morning,

Sometimes we want to count the lines in a txt file. So the code is here. This is just for the small files. It can give error for the huge datas.


file = open('test.txt') 
count = 0
for line in file:
    count += 1