调用另一个函数中定义的函数 [英] Call a function defined in another function
本文介绍了调用另一个函数中定义的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在python3.2的全局范围内调用嵌套在另一个函数中的函数吗?
Can I call a function nested inside another function from the global scope in python3.2?
def func1():
def func2():
print("Hello")
return
return
有没有办法从 func1() 外部调用 func2()?
Is ther a way to call func2() from outside func1()?
推荐答案
否,除非您返回函数:
def func1():
def func2():
print("Hello")
return func2
innerfunc = func1()
innerfunc()
甚至
func1()()
这篇关于调用另一个函数中定义的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文