readlines(), , , .
If you want to be different, you can use the read () member function to get the whole file and count CR, LF, CRLR LFCR character combinations using collections.Counter class.
However, you will have to deal with various ways of completing strings.
Sort of:
import collections
f=open("myfile","rb")
d=f.read()
f.close()
c=collections.Counter(d)
lines1=c['\r\n']
lines2=c['\n\r']
lines3=c['\r']-lines1-lines2
lines4=c['\n']-lines1-lines2
nlines=lines3+lines4
source
share