你可以使用Python来监视CPU占用率, 并将其记录到“CPU.log”文件中。
其中一种方法是使用psutil库, 下面是一个示例代码:
import psutil
import time
while True:
cpu_percent = psutil.cpu_percent()
with open("CPU.log", "a") as f:
f.write(str(cpu_percent) + "\n")
time.sleep(1)
该程序将在每秒钟记录一次CPU占用率,并将其追加到"CPU.log"文件中。
另