Python 类型错误:%d格式:需要数字,而不是元组
我正在运行这个:Python 类型错误:%d格式:需要数字,而不是元组,python,python-2.7,typeerror,Python,Python 2.7,Typeerror,我正在运行这个: def add (a, b): print "ADDING %d + %d" % (a, b) return a + b def subtract (a, b): print "SUBSTRACTING %d - %d" %(a, b) return a -b def multiply (a, b): print "MULTIPLYING %d * %d" % (a, b) return a * b def devide (a,
def add (a, b):
print "ADDING %d + %d" % (a, b)
return a + b
def subtract (a, b):
print "SUBSTRACTING %d - %d" %(a, b)
return a -b
def multiply (a, b):
print "MULTIPLYING %d * %d" % (a, b)
return a * b
def devide (a, b):
print "DEVIDING %d / %d" % (a, b)
return a / b
print " lets do some math with just function!"
age = add(30, 5)
hight = subtract (78, 4)
weight = multiply (90, 2)
iq = divide = (100, 2)
print "Age: %d, Hight: %d, Weight: %d, IQ: %d" % (age, hight, weight, iq)
我明白了:
TypeError: %d format: a number is required, not tuple
但是为什么呢?只是代码中的一些输入错误:
iq = divide = (100, 2)
def devide (a, b):
需要成为
iq = divide(100, 2)
def divide (a, b):
您还应该将divide更改为devide;)或者反过来,把
hight
改成height
,我的天啊,对不起,我现在才知道