擅长:python、mysql、java
<p>因此,您有两个<em>包</em>,第一个包的模块名为:</p>
<pre><code>server # server/__init__.py
server.service # server/service.py
server.http # server/http.py
</code></pre>
<p>第二个模块名为:</p>
^{pr2}$
<p>如果您想假设这两个包都在导入路径(<code>sys.path</code>)中,并且您想要的类在<code>client/client.py</code>中,那么在您的服务器中,您必须执行以下操作:</p>
<pre><code>from client.client import PyCachedClient
</code></pre>
<p>您请求的符号来自<code>client</code>,而不是<code>client.client</code>,根据您的描述,这不是该符号的定义位置。在</p>
<p>我个人会考虑让这个包(也就是说,在文件夹中放一个<code>__init__.py</code>,并给它一个合适的python包名),并将<code>client</code>和{<cd7>}作为该包的子包。然后(a)如果你想(<code>from ...client.client import something</code>),你可以做相对导入,(b)你的项目更适合重新发布,而不是把两个非常通用的包名放在python模块层次结构的顶层。在</p>