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

发布于 2024-10-01 02:27:19 字数 207 浏览 0 评论 0原文

很长一段时间以来第一次使用 Windows,并使用了 notepad++ 并使用 nppexec 插件来运行 python 脚本。但是,我注意到 notepad++ 没有选择保存我的脚本的目录。例如,我将“script.py”放在“我的文档”中,但是 os.getcwd() 打印“Program Files \ Notepad++

”知道如何改变这种行为吗? Mac 上不太习惯。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

澉约 2024-10-08 02:27:19

Notepad++ >nppexec >follow $(当前目录)

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

夕嗳→ 2024-10-08 02:27:19

您可以在脚本的开头放置类似的内容:

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

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

import os
os.chdir(os.path.dirname(__file__))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文