Programming in Python
0 of 222 complete

Section 7: Files · Notes

Section notes

  • open() opens a file and returns a handle you read line by line.
  • for line in handle: is the usual way to read large files.
  • rstrip() removes the newline at the end of each line.
  • Use try and except when the file name comes from the user.

Your progress is saved in this browser. Accounts are coming so it follows you across devices.