Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何从记事本++;但是在脚本的目录中使用powershell和?_Python_Powershell_Notepad++ - Fatal编程技术网

Python 如何从记事本++;但是在脚本的目录中使用powershell和?

Python 如何从记事本++;但是在脚本的目录中使用powershell和?,python,powershell,notepad++,Python,Powershell,Notepad++,如何从在Windows Powershell中打开的Notepad++中运行Python脚本,并从Python脚本所在的目录中运行脚本,即使目录路径中有空格。要在Powershell中运行Python脚本,可以按F5打开“运行”对话框,要在powershell中正常运行python脚本,可以使用 powershell.exe -noexit -command "cd "$(CURRENT_DIRECTORY)"; python -i "$(FULL_CURRENT_PATH)"" 然而,这会以

如何从在Windows Powershell中打开的Notepad++中运行Python脚本,并从Python脚本所在的目录中运行脚本,即使目录路径中有空格。

要在Powershell中运行Python脚本,可以按F5打开“运行”对话框,要在powershell中正常运行python脚本,可以使用

powershell.exe -noexit -command "cd "$(CURRENT_DIRECTORY)"; python -i "$(FULL_CURRENT_PATH)""
然而,这会以一种丑陋的格式打开Powershell,类似于默认情况下的cmd。尽管它确实具有所有功能,但它也不会从目录中运行脚本,因此相对路径不起作用。要使Powershell看起来正常,您应该从“开始”菜单中的快捷方式运行它,如果文件路径中有空格,则应在引号前加上\以使其工作。因此,工作运行命令为:

"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk" -noexit -command cd \"$(CURRENT_DIRECTORY)\"; python -i \"$(FULL_CURRENT_PATH)\"

另外,您可能还想从插件管理器中查看Notepad++NppExec插件。