Q : Why does Python print the formula or the functions "backward"?
A : It's not really backward, it's "inside out." When you start breaking down the function into separate formulas and function calls you'll see how it works. Try to understand what I mean by "inside out" rather than "backward."
from : https://learnpythonthehardway.org/book/ex21.html
1
3pmtea 2017-01-25 19:29:45 +08:00 1
-- 为什么输出的文本是按(与函数名出现的顺序)相反的顺序打印出来的?
-- 准确来说并不是反序,而是(按照函数的调用层次)从里向外的顺序 比如 31 行, what = add(age, subtract(height, multiply(weight, divide(iq, 2)))),函数出现的顺序(正序)是 add - sub - mult - divide ,而在实际执行代码时, python 先确定参数的值,然后才调用函数,这就导致了在最内层的 divide 会最先调用,所以就成了 inside-out |
2
Newyorkcity OP @3pmtea 谢谢,理解了
|