前向引用

前向引用

函数即变量。

1)def test():
print("test")
foo()


def foo():
print("hi")

test()=====结果是 test=====>因为可以查找到函数foo(),所以会有结果
hi

2)

def test():
print("test")
foo()

test()======>结果会报错,因为找不到函数foo()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


posted @ 2021-02-27 16:58  wode110  阅读(58)  评论(0编辑  收藏  举报