search

Home  >  Q&A  >  body text

python在命令行中实时输出数据

想做一个简易的数据监控程序,命令行界面。
python每秒取数据 展示在命令行中,

但是有两个小需求 不知怎么实现 不想要屏幕滚动输出想把屏幕固定,每秒更新命令行中的数据。

什么思路请指点下?

PHPzPHPz2853 days ago542

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 10:36:10

    You may want the effect of top or watch command.

    Suppose your script is called test.py

    You only need to execute watch -n 1 "python test.py"

    You can run watch -n 1 "date" to see the effect

    Reference:
    http://stackoverflow.com/ques...

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 10:36:10

    If you don’t want the screen to scroll but want to see the output, I think you may need to use 'r' instead of 'n'

    reply
    0
  • Cancelreply