而函數定義的順序可有可無python
就如同變量的定義通常函數
a = 1 b = 2 #二者沒什麼不一樣 b = 2 a = 1
例this
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
不能夠這樣blog
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