[英]How to import a Python module with relative path to a file from another directory?
[英]How to create a file containing path and import that file into another python file in the so that the path does not need to be explicitly mentioed?
我想要一个包含路径变量的文件(我的系统的python路径在这里为F:/Python/python.exe),该变量在Windows的wamp的www文件夹中存储的每个python文件的顶部都提到。 然后,我想将该文件导入所有其他文件,这样就不必每次都在文件顶部提到路径。 这可能吗?
我尝试创建一个函数并创建一个存储该变量的变量,但是显然无法完成。 那么如何创建可以导入其他文件的文件。 还是我想要实现的其他解决方案?
您可以尝试这种方式,也许可以帮助您解决问题
这将减少导入声明的后悔
来自您的文件:来自主要导入*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.