一、前向引用
函数即是变量,在调用前要先定义好。
def bar(): print('from bar') def foo(): print('from foo') bar() foo()
def foo(): print('from foo') bar() def bar(): print('from bar') foo()
错误示例:
def foo(): print('from foo') bar() foo() def bar(): print('from bar')
def bar(): print('from bar') def foo(): print('from foo') bar() foo()
def foo(): print('from foo') bar() def bar(): print('from bar') foo()
def foo(): print('from foo') bar() foo() def bar(): print('from bar')