python notepad ++指定参数sys.argv [1]

时间:2022-02-16 23:16:32

I am using notepad++ in Windows to execute my python scripts. I am using NppExec or PyNpp for this purpose and this is working well.

我在Windows中使用notepad ++来执行我的python脚本。我为此目的使用NppExec或PyNpp,这很好用。

However, I can't find nowhere how to specify an argument to the script, in order to simply call my script like this on Linux:

但是,我无法找到如何为脚本指定参数,以便在Linux上简单地调用我的脚本:

$ python myscript.py blah

blah is retrieved in my script by sys.argv[1]

在我的脚本中通过sys.argv [1]检索blah

Is it possible to do such a thing in Notepad++? Is there a plugin to do this?

是否有可能在Notepad ++中做这样的事情?有没有插件可以做到这一点?

Thanks for helping!

谢谢你的帮助!

1 个解决方案

#1


Really the only option you have is to go to NppExec->Execute which should open a dialog.

真的唯一的选择是转到NppExec-> Execute,它应该打开一个对话框。

Then enter python ..\path\to\script\myscript.py blah, replacing ..\path\to\script\ with the full path to your python file. Then whenever you press F6, the program will run. You can follow these steps again to change the argument.

然后输入python .. \ path \ to \ script \ myscript.py blah,将.. \ path \替换为\ script \,并使用python文件的完整路径。然后每按一次F6,程序就会运行。您可以再次按照这些步骤更改参数。

NOTE: Pressing F6 will not open the dialog, it will only run the currently configured execution settings.

注意:按F6不会打开对话框,它只会运行当前配置的执行设置。

#1


Really the only option you have is to go to NppExec->Execute which should open a dialog.

真的唯一的选择是转到NppExec-> Execute,它应该打开一个对话框。

Then enter python ..\path\to\script\myscript.py blah, replacing ..\path\to\script\ with the full path to your python file. Then whenever you press F6, the program will run. You can follow these steps again to change the argument.

然后输入python .. \ path \ to \ script \ myscript.py blah,将.. \ path \替换为\ script \,并使用python文件的完整路径。然后每按一次F6,程序就会运行。您可以再次按照这些步骤更改参数。

NOTE: Pressing F6 will not open the dialog, it will only run the currently configured execution settings.

注意:按F6不会打开对话框,它只会运行当前配置的执行设置。