代码:
# coding=utf-8
# run函数
def run():
print 'This is run!'
# 第一种写法(PEP8规范不推荐)
func = lambda: run()
# 第二种写法
def func2():
return run()
# 第三种写法
def func3(): return run()
if __name__ == "__main__":
print '------ func() ------'
func()
print '------ func2() ------'
func2()
print '------ func3() ------'
func3()
输出:
------ func() ------
This is run!
------ func2() ------
This is run!
------ func3() ------
This is run!