python读文件算数

 #cat 1
1
2
3
#cat 2
4
5
6
########################
import os
acmd='cat 1'
bcmd='cat 2'
a = os.popen(acmd).readlines()
b = os.popen(bcmd).readlines()
i=0
while i<3:
print int(a[i].strip()) + int(b[i].strip())
i+=1

你可能感兴趣的:(python)