• 请不要在回答技术问题时复制粘贴 AI 生成的内容
reaCodes
V2EX  ›  程序员

从 Python 启动另一个程序,这个程序在单独窗口运行,而不是在当前窗口,就是实现双击打开的效果

  •  
  •   reaCodes ·
    zhatlas · May 20, 2020 · 2906 views
    This topic created in 2381 days ago, the information mentioned may be changed or developed.
    启动的时候输入一串字符,并且获得这个被启动程序的 PID,我用了 subprocess 实在不知道怎么实现我的需求,各位请帮忙
    5 replies  •  2020-05-21 08:56:00 +08:00
    ytymf
    ytymf
    May 20, 2020
    1
    Win 的话可以看看这个:
    https://stackoverflow.com/questions/6469655/how-can-i-spawn-new-shells-to-run-python-scripts-from-a-base-python-script

    不过这个事情没那么简单,本质是一个 stdin/stdout/stderr 的重定向的问题。
    imn1
    imn1
    May 20, 2020
    2
    os.system(cmd)
    cmd 用 start 命令
    pid 嘛……
    crella
    crella
    May 20, 2020 via Android
    3
    可以考虑一下 vbscript 辅助打开 cmd 窗口。
    我也没试过。
    hotsymbol
    hotsymbol
    May 20, 2020
    4
    可以试试看用 go-python,在 go 中启动 python
    Sanko
    Sanko
    May 21, 2020 via Android
    5
    start xxxx.exe
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2690 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 10:29 · PVG 18:29 · LAX 02:29 · JFK 05:29
    ♥ Do have faith in what you're doing.