Python打印最常用的10条Linux命令

注:部分内容来自书籍或者网络,如有侵权,请联系删除。

#!/usr/bin/python
# -*- coding:UTF-8 -*-
import os
from collections import Counter

c = Counter()
with open(os.path.expanduser('~/.bash_history')) as f:
    for line in f:
        cmd = line.strip().split()
        if cmd:
            c[cmd[0]]+=1
print(c.most_common(10))


「 文章如果对你有帮助,请点个赞哦^^ 」 

1+