def calculate(parameter_one, parameter_two):
demo = parameter_one % parameter_two
print "%r % %r = %r" % (parameter_one, parameter_two, demo)
错误提示: not all arguments converted during string formatting
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
Python的縮進是個坑
代码应该是这样的:
这不是python取余数出错的问题,而是变量作用域的问题,print是在函数外,不能访问到
calculate
函数中的局部变量demo
的。