Pycharm 社区版 4.5 - 导入 packages/modules
Pycharm Community Edition 4.5 - importing packages/modules
我尝试在 PyCharm Community Edition 4.5 中导入一个模块。
该模块位于带有子文件夹的单独文件夹(包)中...
对于这里的许多程序员来说,这可能是一个简单的问题,但是如何将模块导入到我的项目中才能使用模块中定义的 Class。
更具体一点:
(1) 我有一个包 'pythonds' 这是一个包含多个子文件夹的文件夹
(2) pythonds的路径为:
E:\Tutorials\Python Tutorials\Bioinformatics_Algorithms/pythonds
(3) 在几个子文件夹中有文件夹 'graphs' 包含模块 'adjGraph.py'
E:\Tutorials\Python Tutorials\Bioinformatics_Algorithms\pythonds\graphs\adjGraph.py
(4) 模块 adjGraph.py 包含一个 class 我想导入:
I would like to import the class 'Graph' which is defined in the module adjGraph.py
非常感谢您,
最好的,
维尔纳
这应该有效:
from graphs.adjGraph import Graph
我尝试在 PyCharm Community Edition 4.5 中导入一个模块。 该模块位于带有子文件夹的单独文件夹(包)中...
对于这里的许多程序员来说,这可能是一个简单的问题,但是如何将模块导入到我的项目中才能使用模块中定义的 Class。
更具体一点:
(1) 我有一个包 'pythonds' 这是一个包含多个子文件夹的文件夹
(2) pythonds的路径为:
E:\Tutorials\Python Tutorials\Bioinformatics_Algorithms/pythonds
(3) 在几个子文件夹中有文件夹 'graphs' 包含模块 'adjGraph.py'
E:\Tutorials\Python Tutorials\Bioinformatics_Algorithms\pythonds\graphs\adjGraph.py
(4) 模块 adjGraph.py 包含一个 class 我想导入:
I would like to import the class 'Graph' which is defined in the module adjGraph.py
非常感谢您,
最好的, 维尔纳
这应该有效:
from graphs.adjGraph import Graph