os.system() 调用系统命令
popen() 调用系统命令 将结果存入文件对象
import os
fobj = os.popen('ps -aux')
count = {}
with fobj as f:
for i in f.readlines():
# print(i.split(' '))
if i.split(' ')[0]in count:
count[i.split(' ')[0]] += 1
else:
count[i.split(' ')[0]] = 1
if 'USER'in count:
del count['USER']
print(count)