例如,我有以下源文件:
档案a.py
from b import *
def A():
print 'function A'
B()
return
档案b.py
from a import *
def B():
print 'function B'
A()
return
def main():
A()
B()
return
if __name__ == '__main__':
main()
然后我运行python b.py
,我遇到了以下错误:
NameError: global name 'A' is not defined
完整的信息和印刷品如下:
function A
function B
Traceback (most recent call last):
File "b.py", line 14, in <module>
main()
File "b.py", line 9, in main
A()
File "/home/mypath/a.py", line 5, in A
B()
File "/home/mypath/b.py", line 5, in B
A()
NameError: global name 'A' is not defined
它有什么问题? 谢谢大家的帮助!