如何从记事本中运行 python 脚本?
当我使用 textmate 时,我只需点击“apple+r”,程序就会被解释。如何从 notepad++ 中运行程序?我看到 F5 代表“运行”,但将其指向 Python.exe 只是打开一个运行 python 的终端。它不运行我的脚本。
When I'm using textmate, I simply hit "apple+r" and the program gets interpreted. How can I run a program from within notepad++? I see that F5 is for "Run", but pointing that to Python.exe simply opens up a terminal with python running. It does not run my script.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
插件 NppExec 执行 (F6) 比普通运行 (F5) 功能强大得多。通过插件、插件管理器安装 NppExec。然后在F6中添加/保存以下内容:
在插件NppExec控制台输出过滤器中(Shift+F6)
添加以下HighLight蒙版:
确保选中它,并将其设置为红色并加下划线。
在“F6/execute”时,错误将突出显示并可单击!
这适用于 NPP568,可能更旧。
Plugins NppExec Execute (F6) is much more powerful than plain Run (F5). Install NppExec via Plugins, Plugin Manager. Then in F6 add/save the following:
In Plugins NppExec Console output filters (Shift+F6)
add the following HighLight mask:
Make sure it's checked, and make it e.g. red and underlined.
Upon "F6/execute" errors will be highlighted and clickable !
This works in NPP568, possibly older.
您需要将 FULL_CURRENT_PATH 环境变量传递给程序,如 记事本++维基:
You need to pass through the FULL_CURRENT_PATH environment variable to the program, as described in the notepad++ wiki:
您可以使用 PyNPP 插件 (https://github.com/mpcabd/PyNPP) 来实现此目的。
我知道这已经过时了,但答案是为来自搜索的人提供的。
You can use PyNPP Plugin (https://github.com/mpcabd/PyNPP) to achieve this.
I know this is old but the answer is for people coming from search.
也可以使用 pdb
上面的答案对于让它工作非常有用。然而,一旦我可以运行 python 程序,我还需要与它们交互。我发现了两件事。
possible to use pdb too
The answers above were very useful to get it working. However, once i could run the python programs, I also needed to interact with them. Two things I found out.
如果您有 NppExec 插件(默认情况下),请按 F6 并添加执行脚本的命令
if u have the NppExec plugin (is by default) hit F6 and add the command that exec your script
除非我遗漏了一些东西,否则讨论 NppExec 的其他答案没有提供一种通过单次击键运行脚本的方法,或者(按下 F6 时总是弹出执行对话框,必须先接受该对话框)脚本已运行)。
完成 bjornhb 的回答中的步骤后,您只需按一次键即可运行脚本:
Unless I'm missing something, the other answers discussing NppExec do not provide a way to run the script with a single keystroke or (the execute dialogue box always pops up when F6 is pressed which must be accepted before the script is run).
After completing the steps in bjornhb's answer the following will allow you to run scripts with just one keystroke: