From 9d7ac8b0e9eccec4616f3c60b71cb6669d0fc543 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Sat, 18 Jul 2009 13:32:43 -0400 Subject: [PATCH] typo --- files.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files.html b/files.html index 5dd8b3f..4979725 100644 --- a/files.html +++ b/files.html @@ -225,8 +225,8 @@ ValueError: I/O operation on closed file. print('{} {}'.format(line_number, a_line.rstrip()))
  1. Using the with pattern, you safely open the file and let Python close it for you. -
  2. This is it: to read a file one line at a time, use a for loop. That’s it. Besides having explicit methods like read(), the file object is also an iterator which spits out a single line every time you ask for a value. -
  3. Using the format() string method, you can print out the line number and the line itself. (The a_line variable contains the complete line, carriage returns and all. The rstrip() string method removes the trailing whitespace, including the carriage return characters.) +
  4. To read a file one line at a time, use a for loop. That’s it. Besides having explicit methods like read(), the file object is also an iterator which spits out a single line every time you ask for a value. +
  5. Using the format() string method, you can print out the line number and the line itself. (The a_line variable contains the complete line, carriage returns and all. The rstrip() string method removes the trailing whitespace, including the carriage return characters.)