Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我想制作一个实时显示计算机cpu使用情况的python程序。到目前为止,我正在使用 psutil 模块来查找 cpu 使用情况,但我不确定如何直观地表示输出。
import psutil x=(2) while x>0: cpu = psutil.cpu_percent(interval=1, percpu=False) print(cpu)
我想知道是否有人对我如何显示结果有任何想法。
tkinter 是一个简单的 gui 包,它与 python 捆绑在一起。你可以用那个。
或者您可以每隔一秒左右sys.stdout.write 打印一次结果,在开始时将字符光标带到行首。这将使令人耳目一新的单行终端显示。\n\r
sys.stdout.write
\n
\r