运行此代码时,它显示一个错误,表示第8行中的参数太多。我不确定如何解决它。太多参数的Python错误
#Defining a function to raise the first to the power of the second.
def power_value(x,y):
return x**y
##Testing 'power_value' function
#Getting the users inputs
x = int(input("What is the first number?\n"))
y = int(input("What power would you like to raise",x,"to?\n"))
#Printing the result
print (x,"to the power of",y,"is:",power_value(x,y))
这里是错误...
Traceback (most recent call last):
File "C:\[bla location]", line 8, in <module>
y = int(input("What power would you like to raise",x,"to?\n"))
TypeError: input expected at most 1 arguments, got 3
是的,当它应该是这样的时候,我已经用昏迷来分开它们。谢谢:D – 2014-09-24 16:49:05
不,不应该是这样的。像其他人所建议的那样使用'format'。 – Matthias 2014-09-24 18:24:59
@Matthias“它不应该”?这是为什么?它工作正常。 – CoryKramer 2014-09-24 18:41:01