如何用python提取文本包含特定字符串的整行并生成到一个新的文本文件里

2024-01-14 19:04:55
推荐回答(1个)
回答1:

b=[x for x in open('a.txt').readlines() if x.find('')>-1]
with open('b.txt','w') as f:
    f.writelines(b)