有没有办法从其他 IDE 中的 python 脚本在 notepad++ 中打开文本文件?

is there a way to open text file in notepad++ from python script in other some other IDE?

我正在尝试从记事本 ++ 中用 pycharm 编写的 python 脚本打开一个文本文件 我从之前的答案中发现我们可以使用 python 中的命令子进程模块打开特定文件,但我想打开记事本++在特定行打开文件 我用这个

    import subprocess
    subprocess.call([r"C:\Program Files\Notepad++\notepad++.exe", r"C:\location\myfile.txt"])

但它打开时没有任何特定焦点,但我知道以下命令提示符选项可以使用以下命令行命令在特定行打开我的文本文件

start notepad++ "C:\location\myfile.txt" -n1500

这是在 notepad++ 中突出显示的行号 1500 处打开 myfile.txt,但是当我尝试将 -n(line-number) 添加到 subprocess.call([r"C:\Program Files\Notepad++\notepad++.exe", r"C"\location\myfile.txt"]) 时,它无法执行。有什么方法可以使用子进程或 os 模块在 python 脚本中执行此命令?

是的,您实际上可以,方法是将附加参数附加到已指定的参数列表中。下面应该实现从命令行启动的命令:

subprocess.call([
    r"C:\Program Files\Notepad++\notepad++.exe", r"C:\location\myfile.txt",
    "-n1500"
])