Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个这样的包:
foo/ __init__.py bar.py baz.py
我希望在导入时自动使用子模块的功能foo。因此,如果bar.py有def spam()某个地方,我希望能够像foo.spam(). 实现这一目标的最佳方法是什么?
foo
bar.py
def spam()
foo.spam()
里面__init__.py,做from bar import spam。
__init__.py
from bar import spam