Python文本读取 按关键字查找文件内容,并保存为文件

Python文本读取 按关键字查找文件内容,并保存为文件

from os import replace
import re

file = "d:/gdshnd_scm_0.txt"

with open(file) as f:
    content = f.readlines()

if content:
    for line in content:
        if ("前台" in line) and ("20210324" in line) and ("0247402" in line) and ("10101118" in line):

            # line = re.sub('\t', ',', line)
            # print(line.replace(' ', ''), end='')
            with open('123.txt', 'a') as f:
                f.write(line)

 

上一篇:【致远FAQ】成功升级关键字说明


下一篇:XORMD5加密