from __future__ import division
from math import*
def add(*args):
return sum(args)
def times(*args):
s=1
for i in range(len(args)-1):
s*=args[i]*args[i+1]
return s
def divide(*args):
s=1
for i in range(len(args)-1):
s=args[i]/args[i+1]/s
return s
def sqroot(arg):
return sqrt(arg)
def get(data,s):
if len(data)==1:
s=add(s,int(data))
return s
s=add(s,int(data[data.index('+')-1]))
cut=data[(data.index('+')+1):]
get(cut,s)
user=raw_input()
print str(get(user,0))
为什么函数返回None
而不是s
(如果我打印s
的值是正确的)的值?该函数只是解析一个表达式,如1+1+1
.