author | Puneeth Chaganti <punchagan@fossee.in> |
Tue, 09 Nov 2010 16:16:55 +0530 | |
changeset 424 | 19f49715e83f |
parent 285 | 7c4855fb8e5f |
permissions | -rw-r--r-- |
285 | 1 |
\textbf{Getting Started -- files} |
2 |
||
3 |
\lstinline|f = open('filename')| returns a file object. \lstinline|f| |
|
4 |
can be used to perform further operations on the file. |
|
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
5 |
|
285 | 6 |
\lstinline|f.read()| reads the whole file and returns the contents. |
7 |
||
8 |
\lstinline|f.close()| closes the file. |
|
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
9 |
|
285 | 10 |
\lstinline|for line in open('filename'):| -- iterate over the file |
11 |
line-by-line. |
|
12 |