使用Python 3.7从另一个目录导入文件

时间:2019-06-07 02:35:49

标签: python linux

我在debian(xmonad窗口管理器)和Python版本3.7.3中使用vim。我在同一目录中有两个子目录。我正在尝试导入另一个目录(class6_files_continue)文件名:import_from_a_file(如代码中所示)。

我在两个目录中都插入了__init__.py

from class6.import_from_a_file import save_to_file, read_file

save_to_file('say my name', 'heisenberg.txt')
print(read_file('heisenberg.txt'))

我不断收到错误消息:

ModuleNotFoundError: No module named 'class6'

0 个答案:

没有答案