[英]Calling PowerShell from Python using Notepad++
I thought it might be time to start using PowerShell
instead of cmd
.我认为可能是时候开始使用
PowerShell
而不是cmd
了。 I currently run Python scripts from Notepad++ with the following commnad:我目前使用以下命令从 Notepad++ 运行 Python 脚本:
cmd /c cd "$(CURRENT_DIRECTORY)" &python -i "$(FILE_NAME)"
How should I modify this to get the same behaviour in PowerShell
please?请问我应该如何修改它以在
PowerShell
中获得相同的行为?
I tried我试过了
powershell -noexit cd "$(CURRENT_DIRECTORY)" &python -i "$(FILE_NAME)"
but I got an error about ampersands.但我得到了一个关于&符号的错误。 I know very little about
PowerShell
or cmd
in general - I just use them to run my Python scripts.一般来说,我对
PowerShell
或cmd
- 我只是用它们来运行我的 Python 脚本。
After a bit more digging I found a solution:经过一番挖掘,我找到了一个解决方案:
powershell -noexit cd '$(CURRENT_DIRECTORY)'; python -i '$(FILE_NAME)'
PowerShell
seems to prefer single quotes for paths so I wrapped $(CURRENT_DIRECTORY)
and $(FILE_NAME)
in single quotes. PowerShell
似乎更喜欢使用单引号作为路径,所以我将$(CURRENT_DIRECTORY)
和$(FILE_NAME)
包裹在单引号中。
Also, &
is replaced by ;
此外,
&
被替换为;
for multiple commands.对于多个命令。
If there is a more "correct" way of doing this, please let me know.如果有更“正确”的方法,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.