import re
ex=raw_input()
num="1234567890"
a=re.findall("\d+",ex)
b=re.findall("[+-]",ex)
l=[]
if len(a)==len(b):
for i in range(len(a)):
l.append(int(b[i]+a[i]))
else:#a=b+1
l.append(int(a[0]))
for i in range(1,len(a)):
l.append(int(b[i-1]+a[i]))print sum(l)
表达式计算(re运用)
时间: 2024-11-09 13:05:09