擅长:python、mysql、java
<p>您正在导入<code>general_functions</code>模块,但此时,<code>main.py</code>不知道它的内容(或者更确切地说,不会将其内容加载到<code>main</code>模块中)。你可以:</p>
<p><code>from general_functions import make, bake</code></p>
<p>或者(在我看来,更好的做法):</p>
<pre><code>import general_functions
...
class baking(object):
def __init__(self, ...):
muffin = 'chocolate muffin'
general_functions.make(muffin)
general_functions.bake(200)
</code></pre>
<p>您可以查看这个很棒的线程:<a href="https://stackoverflow.com/questions/10501724/how-does-python-importing-exactly-work">How does Python importing exactly work?</a>关于<code>import</code>在Python中的工作方式,另一个线程:<a href="https://stackoverflow.com/questions/1699108/local-import-statements-in-python">Local import statements in Python</a>关于导入范围。在</p>