Heim  >  Fragen und Antworten  >  Hauptteil

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

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

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

什么思路请指点下?

PHPzPHPz2741 Tage vor491

Antworte allen(2)Ich werde antworten

  • ringa_lee

    ringa_lee2017-04-18 10:36:10

    你可能是想要 top 或者是 watch 命令的效果。

    假设你的脚本名字叫 test.py

    你只需要执行 watch -n 1 "python test.py"

    可以执行看一下效果 watch -n 1 "date"

    参考:
    http://stackoverflow.com/ques...

    Antwort
    0
  • 巴扎黑

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

    不想要屏幕滚动 却又想看到输出, 我觉得你可能需要用'r'代替'n'

    Antwort
    0
  • StornierenAntwort