【发布时间】:2018-02-28 08:28:36
【问题描述】:
我想为我的 python 代码创建一个包。 我的文件夹结构如下:
sing*(this is a folder)*
--ml*(this is a folder)*
----regression*(this is a folder)*
------linear.py*(this is a class file with functions in it)*
----classification*(this is a folder)*
------logistic.py*(this is a class file with functions in it)*
我想通过以下方式访问 linear.py 中的类:
from sing.ml.regression import linear
请告知如何创建这样的包
提前致谢
【问题讨论】:
-
我相信你已经可以从你使用绝对导入的地方访问线性
-
我的消费者应用程序托管在 azure 上。
-
@Shinratensei,你是说如果我在“sing”文件夹中有一个 test.py 文件,那么在 test.py 中我可以通过说“sing.ml”来调用 linear.py 类。回归导入线性”?
-
从我在其他问题中读到的内容,是的,你应该能够
-
不,我收到以下错误“ValueError: Attempted relative import in non-package”
标签: python