Python3 处理DOS环境下tasklist命令的输出(tasklist.py)

来自<<python核心编程第三版>>

源代码是python2,已经改成python3.

import os
import re

f = os.popen('tasklist /nh', 'r')
for eachLine in f:
    print (re.findall(
        r'([\w.]+(?: [\w.]+)*)\s\s+(\d+) \w+\s\s+\d+\s\s+([\d,]+ K)',
        eachLine.rstrip()))
f.close()

猜你喜欢

转载自blog.csdn.net/qq_38115310/article/details/82188195