开发者

How is possible to create a python shell script like top unix command?

I'm need 开发者_高级运维to create a Python shell script that refresh output every n seconds like top unix command. what 's the best way to do this?


One way to do this is to write a script that prints your output (once), and then run your script using the watch command. The watch command will automatically clear the screen and run your script every few seconds (usually 2 by default).

If you really want to do this in pure Python, you can use the curses module, or if you know your terminal is VT100-compatible you can go considerably simpler:

print "\x1b[H\x1b[2J",
print "hello clear world"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜