diff options
Diffstat (limited to 'getting_started_with_files/quickref.tex')
-rw-r--r-- | getting_started_with_files/quickref.tex | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/getting_started_with_files/quickref.tex b/getting_started_with_files/quickref.tex new file mode 100644 index 0000000..17b4d33 --- /dev/null +++ b/getting_started_with_files/quickref.tex @@ -0,0 +1,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. + |