python 获取txt中所有文字,并把还有特定字符串一行数据写到txt中
fp = open("123.txt", "r",encoding='utf-8')
sample = fp.readlines()
file = open("text.txt", "w")
for line in sample:
line = line.strip()
if '2222' in line:
print(line)
file.write(line)
file.write('/n')
fp.close()
共有 0 条评论