import subprocess

top_info = subprocess.Popen(["top", "-n", "1"], stdout=subprocess.PIPE)
out, err = top_info.communicate()

out_info = out.decode('unicode-escape')
lines = []
lines = out_info.split('\n')
print(lines[2].split(',')[4].replace('wa',''))

with open('/usr/local/huanghai.txt','w',encoding='utf-8') as f:
    f.write(lines[2].split(',')[4].replace('wa','').split(' ')[2].split('%')[0]+'%')

 

相关文章:

  • 2021-06-03
  • 2021-11-19
  • 2021-11-24
  • 2021-08-20
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2021-06-12
  • 2022-01-05
  • 2021-07-25
  • 2021-12-01
  • 2022-01-31
相关资源
相似解决方案