访问包含包中的 python 模块

Accessing a python module in the containing package

我有一个 Python 包裹 x 只包含:

x/__init__.py
x/spam.py
x/eggs.py
x/more/beans.py

eggs 可以通过以下方式访问 spam

from . import spam

但是 beans 应该如何在内部访问 spam

from . import spam  <-- error
import spam         <-- error

你应该使用from .. import spam