【问题标题】:Hide python processes and threads output on Windows在 Windows 上隐藏 python 进程和线程输出
【发布时间】:2014-09-02 08:25:47
【问题描述】:

我有一个运行 python 进程的 Windows CMD。该进程同时使用 python 多处理和线程运行更多进程。

该进程的所有打印输出都进入同一个 CMD 窗口。有什么办法可以隐藏所有进程输出?

我尝试使用下一个 CMD 命令执行此操作,但它没有隐藏输出。

start "time_tester" C:\Windows\system32\cmd.exe /k C:\Python26\python.exe time_test.py > nul

【问题讨论】:

  • 我正在使用 ghostscript 模块,我的问题是隐藏模块输出,而不是我的打印。我也在尝试在 ghostscript 模块上添加: f = open('nul', 'w') sys.stdout = f .. 但没办法
  • 你可能想使用子进程

标签: python windows multiprocessing output python-multithreading


【解决方案1】:

将 /b 添加到 CMD 命令并将输出重定向到 nul (> nul) 解决了我的问题。这样,所有进程和子进程都将输出返回到同一个 CMD,现在我们可以将其重定向到 nul。

start /b "Name" C:\Windows\system32\cmd.exe /k C:\Python26\python.exe script.py > nul 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-11
    • 2012-07-01
    • 1970-01-01
    • 2012-04-06
    • 1970-01-01
    相关资源
    最近更新 更多