sum(1 for _ in f) how to count the total number of lines in a text file using python
https://stackoverflow.com/questions/19001402/how-to-count-the-total-number-of-lines-in-a-text-file-using-python
with open('data.txt') as f:
print sum(1 for _ in f)
浙公网安备 33010602011771号