我正在制定一个程序,以查找已征税的金额并将其与小费结合在一起。我正在研究小费和介绍。代码:print "Welcome \nEnter The Amount Of Money For the Transaction"amount = raw_inputprint "Taxed Amount Below\n"taxed = (amount * float((1.065)))print taxed这就是我得到的:>>> runfile('/home/meyer/.spyder2/temp.py', wdir='/home/meyer/.spyder2')Welcome Enter The Amount Of Money For the TransactionTaxed Amount BelowTraceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile execfile(filename, namespace) File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile builtins.execfile(filename, *where) File "/home/meyer/.spyder2/temp.py", line 8, in <module> taxed = (amount * float((1.065)))TypeError: unsupported operand type(s) for *: 'builtin_function_or_method' and 'float'>>> 我知道我不能乘以这个浮点数,但是我找不到其他方法。甚至MPMath我正在使用python 2.7
2 回答

jeck猫
TA贡献1909条经验 获得超7个赞
您的代码无法正常运行,因为您需要在之后添加参数raw_input,请尝试以下操作:
print "Welcome \nEnter The Amount Of Money For the Transaction"
amount = float(raw_input())
print "Taxed Amount Below\n"
taxed = (amount * float((1.065)))
print taxed
添加回答
举报
0/150
提交
取消