Python3 模块打包文件结构和初始化文件

Python3 module pakaging files structure and init file

我有 Python 模块,文件中只有一个文件和一个函数。我已经将它上传到 pypi,并使用以下结构对其进行打包,但是当我调用它在模块文件中的函数时,我收到此错误:

AttributeError: module 'effInput' has no attribute 'ask'

('ask' 是函数名)。

模块包结构:

|--effInput
    |--__init__. py
    |--effInput.py (module file) 
|--setup.py
|--readme.txt
|--LICENSE

初始化.py文件:

import effInput
name="EffInput"

我做错了什么?

当你这样做时,你必须调用 effInput.effInput.ask 而不是 effInput.ask。如果您在 __init__.py 中执行了 from effInput import *,它应该会按预期工作。