file_object

#!/use/bin/python
#encoding=utf-8

filename="WinPMT.log"
filename_1="WinPMT_stress.txt"

with open(filename_1,"w") as file_object_1:
    file_object_1.write("")
with open(filename) as file_object:
    lines=file_object.readlines()

for line in lines:
    if "error"in line or "Cycle:" in line:
        print(line)
        with open(filename_1,'a') as file_object_1:
            file_object_1.write(line)

转载于:https://www.cnblogs.com/zzl112893/p/10168965.html

你可能感兴趣的:(file_object)