Python程序教程

您现在的位置是:首页 >  Python

当前栏目

python删除文件中指定内容

python,删除,文件,指定,内容
2025-03-28 09:01:05 时间

大家好,又见面了,我是你们的朋友全栈君。

lines = [l for l in open("file.txt", "r") if l.find("20150723", 0, 8) != 0]
fd = open("file.txt", "w")
fd.writelines(lines)
fd.close()

开头是20150723的行删除

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/139368.html原文链接:https://javaforall.cn