def testB(): print ('---- testB start----') print ('这里是testB函数执行的代码...(省略)...') print ('---- testB end----') def testA(): print ('---- testA start----') testB() print ('---- testA end----') testA()
运行结果:
---- testA start----
---- testB start----
这里是testB函数执行的代码...(省略)...
---- testB end----
---- testA end----
小总结:
- 一个函数里面又调用了另外一个函数,这就是所谓的函数嵌套调用
- 如果函数A中,调用了另外一个函数B,那么先把函数B中的任务都执行完毕之后才会回到上次 函数A执行的位置