Outline for February 15, 2012

Reading: §13

  1. File I/O
    1. Opening and closing: open(filename, mode), close()
    2. Reading: readline(), readlines(), read(), read(n)
    3. Writing: write(str), writelines(list)
  2. Examples
    1. Print out a named file [fileio1.py]
    2. Print out a named file and prepend line numbers [fileio2.py]
    3. Store the output in filename.lst [fileio3.py]
  3. Reading a URL [geturl.py]
    1. Opening a URL
    2. Reading the page as a string (utf-8, us-ascii, iso-8859-1, etc.)

A PDF version is available here.
ECS 10, Basic Concepts of Computing
Winter Quarter 2012