0


python扫描TXT文件,提取关键字,追加到新列表

f = open('SelfCheck.Log', 'r')
txt_content = f.read()
changeline_num = txt_content.count('\n')
f.close()
f = open('SelfCheck.Log', 'r')
txt_content = f.readlines()
# print(txt_content)
# print(changeline_num)
# print(type(txt_content))
i = 0
list = []
while i < (changeline_num):
    str = txt_content[i]
    # print(str)
    if 'Status: 100' in str:
        list.append(str)

    i += 1

print(len(list))

f.close()
标签:

本文转载自: https://blog.csdn.net/qq_20936333/article/details/119820157
版权归原作者 qq_20936333 所有, 如有侵权,请联系我们删除。

“python扫描TXT文件,提取关键字,追加到新列表”的评论:

还没有评论