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

扶醉桌前 提交于 2020-01-12 21:00:10

问题


Using windows for the first time in quite awhile and have picked up notepad++ and am using the nppexec plugin to run python scripts. 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++"

Does anyone know how to change this behavior? Not exactly used to it in Mac.


回答1:


Notepad++ >nppexec >follow $(current directory)




回答2:


You could put something like this at the beginning of your script:

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


来源:https://stackoverflow.com/questions/4103085/getting-nppexec-to-understand-path-of-the-current-file-in-notepad-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!