可以将Python脚本导入另一个(Python)
所以我有两个 python 脚本 - main.py 和 gui.py 在同一目录/文件夹中。但是当我尝试在 gui.py
中导入 main.py
时,它不起作用。当我尝试在 main.py
中导入 gui.py
时也是如此,
我尝试了这种方式
So I have two python scripts- main.py and gui.py in the same directory/folder. But when I try to import main.py
in gui.py
, it doesn't work. It's the same when I try to import gui.py
in main.py
I tried it this way ????
from main import *
I saw several questions about similar things but nothing works. Please help and thanks in advance! I'm using Pycharm and Python 3.10
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从 。 import main
然后,要调用属于 main.py 的函数,你应该这样做;
main.函数名()
from . import main
and then, to call a function that belongs to main.py, you should do;
main.function_name()