如何等待子进程控制台上开始输出实时结果?

2024-04-25 01:31:09 发布

您现在位置:Python中文网/ 问答频道 /正文

用例:

在Windows CMD shell中调用命令。等待控制台上的输出(日志)开始出现。控制台上的输出(日志)不能在后台运行。你知道吗

import subprocess 
from subprocess import CREATE_NEW_CONSOLE
command="cmd /K appium -p 4723"
#This open a new cmd shell for above command
proc=Popen(command,creationflags=CREATE_NEW_CONSOLE)
#Need to write further code , based on wait till the logging started

期望值: 要等到控制台上的日志记录开始吗

登录控制台。

[Appium] Welcome to Appium v1.7.0
[HTTP] Could not start REST http interface listener. The requested port may already be in use. Please make sure there is no other instance of this server running already.

Tags: toimport命令cmdnewwindowscreateshell