一个段代码定义如下,下列调用结果正确的是? def bar(multiple): def foo(n): return multiple ** n return foo print bar( 2 )( 3 ) 正确答案: A 你的答案: 空 (错误)bar(2)(3) == 8 bar(2)(3) == 6 bar(3)(2) == 8 bar(3)(2) == 6 1.执行bar函数 bar(2) 返回内层函数foo 传入私有变量 multiple=2 2.执行foo函数 bar(2)(3) -> foo(3) -> 2 * 2 *2 -> 8 1
|
|