read()

File methods that read text: read() returns the whole rest of the file as one string, readline() one line and readlines() a list of lines.

In more detail

Lines keep their newline characters, so strip them before comparing. For a big file, loop over the file object instead, which reads one line at a time without loading everything into memory.

Related terms

Taught in

References