Man kan:
import os
import sys
import string
if not sys.argv[1:] :
print "You must specify input and output files"
sys.exit()
try :
inFile = open(sys.argv[1], 'rt')
except :
print "Failed to open file"
sys.exit()
Cont = True
while Cont :
try :
line = inFile.readline()
words = string.split(line)
n1 = int(words[0])
n2 = int(words[1])
print str(n1) + " + " + str(n2) + " = " + str(n1 + n2)
except :
Cont = False
inFile.close()
Jeg ved meget lidt om Python, der findes måske bedre måder...