如何在 PyCharm 中自动运行 Main.py [英] How to run Main.py automatically in PyCharm
问题描述
我更喜欢在我的项目中使用类似于 Java 的组织.例如,每个类都有一个不同的.py
文件以及Main
类,它只包含main函数.
I prefer using a Java-like organization with my projects. For instance, each class has a different .py
file as well as class Main
, which only contains main function.
每次在我的一个类中进行更改时,我都需要单击 Main 并从那里运行代码 (Ctrl+Shift+F10)
.
Each time I make a change in one of my classes, I need to click on Main and run the code (Ctrl+Shift+F10)
from there.
如何像在 Eclipse 中一样将我的 Main
类定义为我的 main()
函数?
How can I define my Main
class as my main()
function just as in Eclipse?
推荐答案
您可以像在 Eclipse 中一样创建运行配置".
You can create "run configurations" like in Eclipse.
下拉列表中事物的名称是您想要的运行,不应在更改文件之间更改.单击三角形(或在 eclipse 键盘映射下使用 alt-shift-X)应运行该配置.在下拉列表中,您可以选择要运行的任何文件.
The name of the thing in the dropdown is the run that you want and should not change between changing files. Clicking the triangle (or using alt-shift-X under the eclipse keymap) should run that configuration. In the dropdown you have the option of selecting whatever file you want to run.
这篇关于如何在 PyCharm 中自动运行 Main.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!