在python中运行子过程后继续执行下一行执行

发布于 2025-02-05 05:58:43 字数 245 浏览 1 评论 0原文

的代码行

if __name__ == '__main__':
    subprocess.run('"C:/Windows/System32/notepad.exe"')
    print("hiiiiii")

以下是打开notepad.exe ,但是直到我关闭notepad.exe,print(“ hiiiiiii)才执行 就我而言,我想在打开Notepad.exe之后执行打印(“ hiiiiii”)

Below is the lines of code

if __name__ == '__main__':
    subprocess.run('"C:/Windows/System32/notepad.exe"')
    print("hiiiiii")

In this case notepad.exe is opened , but print("hiiiiiii) is not executed until i close notepad.exe
In my case i want to have the print("hiiiiii") to be executed after notepad.exe is opened

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

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

发布评论

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

评论(1

ゝ杯具 2025-02-12 05:58:44

subprocess.run()阻止主进程,popen()而不是

if __name__ == '__main__':
    subprocess.Popen('"C:/Windows/System32/notepad.exe"')
    print("hiiiiii")

subprocess.run() blocks the main process, Popen() instead

if __name__ == '__main__':
    subprocess.Popen('"C:/Windows/System32/notepad.exe"')
    print("hiiiiii")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文