编写程序从文件读取表达式,执行计算,输出计算结果
f=open('D:/2.txt')
for b in f:
b=b.strip()
for c in b:
if c<'0':
n=b.index(c)
print('%2s'%b[:n],c,'%-2s'%b[n+1:],'=',eval(b))
break
f.close()
编写程序从文件读取表达式,执行计算,输出计算结果
f=open('D:/2.txt')
for b in f:
b=b.strip()
for c in b:
if c<'0':
n=b.index(c)
print('%2s'%b[:n],c,'%-2s'%b[n+1:],'=',eval(b))
break
f.close()