当前位置: 动力学知识库 > 问答 > 编程问答 >

Python: open cmd and stream text output

问题描述:

I want to open a new cmd window and stream some text output (logs) while my python script is running (this is basically to check where I am in the script)

I can't find w way to do it and keep it open and stream my output.

Here is what I have now:

import os

p = os.popen("start cmd", mode='w')

def log_to_cmd(process, message):

p.write(message)

for i in range(10):

log_to_cmd(p, str(i))

And I want to get 0 to 9 output on the same cmd window already open.

Thanks a lot for any suggestion.

网友答案:

use Baretail this software allows you to stream logs.

If you want to stick to cmd shell I'd suggest installing something like GNU Utilities for Win32. It has most favourites, including tail. tail which allows you to open file like a log veiwer .

分享给朋友:
您可能感兴趣的文章:
随机阅读: