Home  >  Article  >  Development Tools  >  How to set a shortcut to directly run python code in notepad++

How to set a shortcut to directly run python code in notepad++

藏色散人
藏色散人forward
2020-06-19 13:17:384077browse

The following tutorial column from notepad will introduce you to the method of running python directly in notepad. I hope it will be helpful to friends who need it!

How to set a shortcut to directly run python code in notepad++

How to run python code directly in notepad ?

Press F5 in the notepad interface (or select "Run" in the menu bar), and the following interface will appear (it is empty for the first time):

Then enter: cmd /k D:\Python27\python.exe "$(FULL_CURRENT_PATH)" & PAUSE & EXIT

The red marked part is the path to the python program source file. Because I installed

under the root directory of drive D. If you want to use shortcut keys, click "Save" and the following interface will appear:

Use the arrangement and combination of these keys, and then add the name, you can use this shortcut key to run the python program, and there will be no black screen. (It has appeared before)

保存ok,设置快捷键。运行。
之后每一次需要运行python脚本的时候,只需要按下所设置的快捷键即可。
我设置的是alt+p  Name为“运行”

You can see it in Settings-Manage Shortcut Keys

Explanation:

cmd :打开命令提示符程序
/k :执行后面的命令,相当于把后面的内容复制到命令提示符里执行
..\python.exe :python.exe的路径
$(FULL_CURRENT_PATH) :Notepad++的宏定义,获取当前文件路径,在cmd里需要用双引号将路径括起来。
& :连接多条命令,x & y & z 意味着先执行x,然后执行y,然后执行z
pause、exit 为cmd的指令,指暂停、退出
所以整条命令的意思就是,打开cmd,执行python.exe,运行当前文件,运行结束暂停,按任意键退出cmd。


The above is the detailed content of How to set a shortcut to directly run python code in notepad++. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete