关于python文本处理
迷茫
迷茫 2017-04-17 17:05:32
0
3
470
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
大家讲道理
import re

def getProcesses(usage=80.0, filename='performance.txt'):
    with open(filename) as f:
        lines = f.readlines()
        for line in lines:
            m = re.search('^\d+.*\s+(\d+\.\d+)\s+(\d+\.\d+).*\:', line)
            if m:
                cpu_usage = m.group(1)
                if float(cpu_usage) > usage:
                    print "CPU: ", cpu_usage
                    print line

getProcesses()
阿神

Put the serial number and processed text into a tuple, then store the tuple in a list, and then arrange it according to the serial number in the tuple.
Try it?

巴扎黑

import psutil

imoprt Dafa is good

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!