Uni Graz logo

CMS 1

Strings

Gerald Senarclens de Grancy <cms@senarclens.eu>

Google Summer of Code

Terminology

String Operations

Substrings

For Loops

Reading Files

  1. Open the file with open(.)
  2. Read the file with read(), readline(), readlines() or iterate over its content
  3. Close the file with close() or implicitly (end of with)
  4. However, the newer and better way to read files is (instead of the above!)
    with open(filename, encoding='utf-8') as f:
        for line in f:
            print(line, end="")
    
    note: filename is a variable that needs to contain a string denoting a filename

Homework and Required Reading

Summary

Questions
and feedback...

Further Reading

Paul Barry and David Griffiths Head First Programming O'Reilly (2009)
Mark Pilgrim Dive Into Python 3 (2nd edition) Apress (October 23, 2009)
Python Software Foundation Python Documentation http://docs.python.org/py3k/