如果用python删除带有特定内容的某一行,请用代码演示一下
时间: 2023-03-13 08:46:39 浏览: 62
可以使用以下代码:with open('filename.txt', 'r') as f:
lines = f.readlines()
with open('filename.txt', 'w') as f:
for line in lines:
if '特定内容' not in line:
f.write(line)
阅读全文