更新时间:2023-10-23 14:24:16
请注意,Folder1
是目录,.py
脚本是您的模块.
Note that Folder1
is a directory, the .py
scripts are your modules.
在pyscript3
中,您应该可以:
from Folder1 import pyscript1
然后,您可以访问名称为methodname
的方法,例如:
Then you can access a method with name methodname
like:
pyscript1.methodname()
否则,您可以直接导入该方法,例如:
Otherwise you can import the method directly like:
from Folder1.pyscript1 import methodname
并像这样使用它:
methodname()
要让程序查看Folder1
和Folder2
,您需要从MainProject
文件夹运行程序.
For your program to see Folder1
and Folder2
, you need to run your program from the MainProject
folder.
将pyscript3
移至MainFolder
或编写另一个脚本,将其称为main.py
,然后调用必要的代码以实例化该类/在pyscript3.py
中调用所需的函数.
Either move pyscript3
to your MainFolder
or write another script, let's call it main.py
, and call the necessary code to instantiate the class/call the function you want in pyscript3.py
.
总而言之,您始终希望从项目的基本文件夹中运行入口模块.
To summarize, you always want to run the entry module from the base folder of your project.