我想让用户输入字符串,例如2+5-3+6并返回10。如果用户输入c,则将打印答案。当用户输入c.
print 'This is a calculator. Please follow the instruction.'
temp = 0
string = 0
def asmd(string):
print 'Your answer is', eval(str(string))
while temp != 'c':
print 'Please enter a number or operation. Enter c to complete. :'
temp = raw_input()
string = str(string)+str(temp)
if temp == str('c'):
asmd(string)