函数定义和调用顺序不能搞乱,在shell中示例代码如下:
#first() 在该处调用first(),会抛出错误,因为first()函数还没定义
def first():
second()
print(1)
#first() 在该处调用first(),会抛出错误,因为second()函数还没定义
def second():
print(2)
first() #在该处可以正确调用函数first(),second()
函数定义和调用顺序不能搞乱,在shell中示例代码如下:
#first() 在该处调用first(),会抛出错误,因为first()函数还没定义
def first():
second()
print(1)
#first() 在该处调用first(),会抛出错误,因为second()函数还没定义
def second():
print(2)
first() #在该处可以正确调用函数first(),second()