简体   繁体   English

让NppExec了解Notepad ++中的当前文件的路径(对于Python脚本)

[英]Getting NppExec to understand path of the current file in Notepad++ (for Python scripts)

Using windows for the first time in quite awhile and have picked up notepad++ and am using the nppexec plugin to run python scripts. 在很长一段时间内第一次使用Windows并且已经选择了notepad ++并使用nppexec插件来运行python脚本。 However, I noticed that notepad++ doesn't pick up the directory that my script is saved in. For example, I place "script.py" in 'My Documents' however os.getcwd() prints "Program Files \\ Notepad++" 但是,我注意到notepad ++没有选择保存我的脚本的目录。例如,我将“script.py”放在“我的文档”中,但os.getcwd()打印“Program Files \\ Notepad ++”

Does anyone know how to change this behavior? 有谁知道如何改变这种行为? Not exactly used to it in Mac. 在Mac上并不完全习惯它。

Notepad ++> nppexec>关注$(当前目录)

You could put something like this at the beginning of your script: 你可以在脚本的开头加上这样的东西:

import os
os.chdir(os.path.dirname(__file__))

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

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