在Python 2.7:类型错误:不支持的操作数类型(S)为/: '海峡' 和 '廉政'
a=80
b=100
def status(hp, maxhp):
print "You are at %r percent health." % hp*100/maxhp
status(a,b)
返回:
TypeError: unsupported operand type(s) for /: 'str' and 'int'
我已经试图把INT()围绕每个变量和每个变量组合。
谢谢,我从来没有告诉我们,模量被认为在这种情况下的操作,或者它的操作顺序站。我最终通过制作另一个变量并将其送入字符串来修复它。 – foltor
为更正确的答案进行编辑。 –