擅长:python、mysql、java
<p>您的代码中有循环导入:同一个模块既是某个模块所必需的,又需要使用另一个模块,当您这样想时,它显然是不稳定的。大多数问题都可以通过使用<code>import a</code>和稍后引用<code>a.b</code>而不是<code>from a import b</code>或{<cd4>}来解决。在</p>
<p>尤其是,<em>从不</em>使用<code>from a import *</code>。通配符导入会使名称空间混乱,使代码的可维护性、可读性、理智性和可预测性降低。<code>import a</code>和<code>from a import *</code>之间的区别在于将一个盒子拖进房间和把里面的东西倒在地板上的区别。在</p>
<p>如果您可以将共享代码移到它自己的模块中,或者以某种方式重构以消除循环导入的需要,那就更好了。循环导入总是指示设计问题。在</p>