以下是我的文件夹结构:
/ Thermal_Formatter
Thermal_Formatter.py
__init__.py
test.py
在Thermal_Formatter.py
我有一个方法:
def processAndPrint(text):
在test.py
中,这不起作用:
import Thermal_Formatter
Thermal_Formatter.processAndPrint(something)
但事实上:
import Thermal_Formatter.Thermal_Formatter
Thermal_Formatter.Thermal_Formatter.processAndPrint(something)
为什么我在import语句和模块调用中写了两次模块名就可以了?你知道吗
因为
Thermal_Formatter
模块位于同名的包中。尝试:如果你想用更理智的方法来使用它。你知道吗
相关问题 更多 >
编程相关推荐