python获取文件行数

    count = 0
    with open('/cm/com.file','rb') as f:
        while True:
            buffer = f.read(1024*8192)
            if not buffer:
                break
            count += buffer.count(b"
")
    print(count)
原文地址:https://www.cnblogs.com/wt11/p/14064225.html