简体   繁体   English

我正在尝试在notepad ++中设置python,但它无法理解我的文件路径中是否有空格

[英]I'm trying to set up python in notepad++ and it can't understand my filepath that has a space in it

I'm using this tutorial: https://silentcrash.com/2016/12/run-python-script-notepad/ 我正在使用本教程: https : //silentcrash.com/2016/12/run-python-script-notepad/

The example for Python 3 includes the folder "Program Files (x86)", which I assume is not necessary, but I would still like to know how to fix this problem if it comes up in the future and I don't have another way of doing it. Python 3的示例包括文件夹“ Program Files(x86)”,我认为这不是必需的,但是我仍然想知道如果将来出现此问题时如何解决此问题,而我没有其他方法做到这一点。

So what happens is that the program assumes the space is the end of the command and it move on to the argument as seen here: 因此,发生的情况是程序假定空格是命令的结尾,并且继续前进到参数,如下所示:

The Program to Run 要运行的程序

Error 错误

The system cannot find the file specified.
An attempt was made to execute the below command.
------------------------------------------------
Command: C:\Program
Arguments: Files\Python37\Lib\idlelib.py "new 2"
Error Code: 2

Is there any way to write the file path such that it won't be split up like this? 有什么办法可以写入文件路径,从而不会像这样被分割?

You need to surround your arguments with quotes when they contain spaces. 当参数包含空格时,需要用引号将其引起来。 In your example, you would use the following command in the Run... dialog: 在您的示例中,您将在“运行...”对话框中使用以下命令:

"C:\Program Files\Python37\Lib\idlelib.py" "$(FULL_CURRENT_PATH)"

I found a helpful hint on superuser.com that will stop the console window from closing when your script finishes. 我在superuser.com上找到了一个有用的提示,该提示将在脚本完成后停止关闭控制台窗口。 However, note that it now needs an extra set of quotes. 但是,请注意,它现在需要一组额外的引号。

cmd /k ""C:\Program Files\Python37\Lib\idlelib.py" "$(FULL_CURRENT_PATH)""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM