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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章