file_object

Posted zzl112893

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)
















以上是关于file_object的主要内容,如果未能解决你的问题,请参考以下文章