在 PyDev 中执行默认的 .py 文件

发布于 2024-12-28 07:11:22 字数 234 浏览 3 评论 0原文

我正在 Eclipse 中使用 PyDev 做一个 Python 项目。我有一个“主”文件和一些“类”文件。我主要在类中工作,但我需要通过主文件执行代码。

目前我需要切换到主文件,或者使用运行/调试按钮的下拉菜单来执行主文件。按下按钮或使用 F11,只运行类文件(这是无用的)

有没有办法让 PyDev 始终运行项目中的特定文件,或者也许始终运行最后执行的文件(这可能是最好的解决方案) 。

提前致谢 :)

I'm doing a Python project in Eclipse with PyDev. I have a "main" file and some "class" files. I primarily work in the classes, but I need to execute the code via the main file.

At the moment I need to either switch to the main file, or use the drop down menu of the run/debug-button to execute the main file. Pressing the button or using F11, just runs the class file (which is useless)

Is there a way to let PyDev always run a specific file in a project, or perhaps always run the last file executed (which probably will be the best solution).

Thanks in Advance :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白云悠悠 2025-01-04 07:11:22

当然(重新启动上次启动实际上是 Eclipse 3.2 中的默认设置,从来不明白他们为什么改变这一点)...

您可以将其返回到首选项中: window > >偏好>运行/调试>启动并将启动操作设置为始终启动先前启动的应用程序

因此,Ctrl+F11 将重新启动上次启动,F11 将调试上次启动...

要启动文件,您可以:

  • 使用快捷方式:F9 运行当前打开的文件
  • 转至菜单: Alt + R + S + 您想要的 Run 编号(可以是 Python、Jython、unit -测试等)。
  • 如果您正在使用单元测试,您可以使用: Ctrl+F9 从当前模块运行单元测试(甚至选择应该运行哪些测试)。
  • 重新启动您之前执行的其他启动:Alt + R + T 并选择之前的启动来重新启动。
  • 您还可以通过右键单击文件夹 > 以单元测试模式启动文件夹下的所有文件。运行为> Python 单元测试

(参考:http://pydev.org/manual_101_run.html

)使用单元测试,您可能还想看看:使用 Pydev(Python 和 Eclipse)进行连续单元测试

Surely (relaunching the last launch was actually the default in in Eclipse 3.2, never understood why they changed that)...

You can have that back in the preferences at: window > preferences > Run/Debug > Launching and set the Launch Operation to Always launch the previously launched application.

So, Ctrl+F11 will relaunch the last launch and F11 will debug the last launch...

And to launch the file initially you may:

  • Use a shortcut: F9 to run the current opened file
  • Go to the menu: Alt + R + S + The number of the Run you wish (It can be Python, Jython, unit-test, etc).
  • If you are using unit-tests, you could use: Ctrl+F9 to run the unit-tests from the current module (and even selecting which tests should be run).
  • Relaunch some other launch you did previously: Alt + R + T and choose a previous launch to relaunch.
  • You may also launch in unit-test mode all files beneath a folder by right clicking the folder > run as > Python unit-test

(reference: http://pydev.org/manual_101_run.html)

And if you use unit-tests, you may also want to take a look at: Continuous unit testing with Pydev (Python and Eclipse)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文