python 前向引用

即函数调用在函数定义之前

可以这样

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

  

上一篇:Linux Shell常用快捷键


下一篇:清除数据库中大于10W行的垃圾历史数据