How to count lines in a text file ?
Andrew Dalke
adalke at mindspring.com
Wed Sep 22 15:48:21 EDT 2004
More information about the Python-list mailing list
Wed Sep 22 15:48:21 EDT 2004
- Previous message (by thread): How to count lines in a text file ?
- Next message (by thread): How to count lines in a text file ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bengt Richter wrote:
> or, if you _are_ willing to read in the whole file,
>
> open('text.txt').read().count('\n')
Except the last line might not have a terminal newline.
Andrew
dalke at dalkescientific.com
- Previous message (by thread): How to count lines in a text file ?
- Next message (by thread): How to count lines in a text file ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list