前向引用
阿新 • • 發佈:2017-06-03
rac recent har 函數調用 file back 前向引用 lin error:
函數定義 在 函數調用 之前
而函數定義的順序無關緊要
就如同變量的定義一般
a = 1 b = 2 #兩者沒什麽不同 b = 2 a = 1
例
def bbb(): print(‘this is b‘) aaa() def aaa(): print(‘this is a‘) bbb() #---------> this is b this is a
def aaa(): print(‘this is a‘) def bbb(): print(‘this is b‘) aaa() bbb() #-----------> this is b this is a
不可以這樣
def bbb(): print(‘this is b‘) aaa() bbb() def aaa(): print(‘this is a‘) #---------> Traceback (most recent call last): this is b File "E:/pycharm/TEST.py", line 600, in <module> bbb() File "E:/pycharm/TEST.py", line 599, in bbb aaa() NameError: name ‘aaa‘ is not defined
前向引用