This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,6 @@
my_file = open(filename, 'r')
try:
for line in my_file:
pass # process line, includes newline
finally:
my_file.close()

View file

@ -0,0 +1,5 @@
from __future__ import with_statement
with open(filename, 'r') as f:
for line in f:
pass # process line, includes newline

View file

@ -0,0 +1,2 @@
line = my_file.readline() # returns a line from the file
lines = my_file.readlines() # returns a list of the rest of the lines from the file

View file

@ -0,0 +1,3 @@
import fileinput
for line in fileinput.input():
pass # process line, includes newline