Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/File-input-output/Python/file-input-output-3.py
Normal file
20
Task/File-input-output/Python/file-input-output-3.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import sys
|
||||
try:
|
||||
infile = open('input.txt', 'r')
|
||||
except IOError:
|
||||
print >> sys.stderr, "Unable to open input.txt for input"
|
||||
sys.exit(1)
|
||||
try:
|
||||
outfile = open('output.txt', 'w')
|
||||
except IOError:
|
||||
print >> sys.stderr, "Unable to open output.txt for output"
|
||||
sys.exit(1)
|
||||
try: # for finally
|
||||
try: # for I/O
|
||||
for line in infile:
|
||||
outfile.write(line)
|
||||
except IOError, e:
|
||||
print >> sys.stderr, "Some I/O Error occurred (reading from input.txt or writing to output.txt)"
|
||||
finally:
|
||||
infile.close()
|
||||
outfile.close()
|
||||
Loading…
Add table
Add a link
Reference in a new issue