版权声明:本文为小盒子原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35393693/article/details/84205070
1. 什么是循环导入
a.py
from b import b
print '---------this is module a.py----------'
def a():
print("hello, a")
b()
a()
b.py
from a import a
print '----------this is module b.py----------'
def b():
print("hello, b")
def c():
a()
c()
运行python a.py
2. 怎样避免循环导入
1. 程序设计上分层,降低耦合
2. 导入语句放在后面需要导入时再导入,例如放在函数体内导入