summaryrefslogtreecommitdiff
path: root/getting_started_with_files/quickref.tex
blob: 17b4d331ec7f490262a002df99f645d211e8ade9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
\textbf{Getting Started -- files}

\lstinline|f = open('filename')| returns a file object. \lstinline|f|
can be used to perform further operations on the file. 

\lstinline|f.read()| reads the whole file and returns the contents. 

\lstinline|f.close()| closes the file. 

\lstinline|for line in open('filename'):| -- iterate over the file
line-by-line.