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

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

  •  
  •   reaCodes ·
    zhatlas · May 20, 2020 · 2606 views
    This topic created in 2208 days ago, the information mentioned may be changed or developed.
    启动的时候输入一串字符,并且获得这个被启动程序的 PID,我用了 subprocess 实在不知道怎么实现我的需求,各位请帮忙
    5 replies    2020-05-21 08:56:00 +08:00
    ytymf
        1
    ytymf  
       May 20, 2020
    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
        2
    imn1  
       May 20, 2020
    os.system(cmd)
    cmd 用 start 命令
    pid 嘛……
    crella
        3
    crella  
       May 20, 2020 via Android
    可以考虑一下 vbscript 辅助打开 cmd 窗口。
    我也没试过。
    hotsymbol
        4
    hotsymbol  
       May 20, 2020
    可以试试看用 go-python,在 go 中启动 python
    Sanko
        5
    Sanko  
       May 21, 2020 via Android
    start xxxx.exe
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2893 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 05:02 · PVG 13:02 · LAX 22:02 · JFK 01:02
    ♥ Do have faith in what you're doing.