python删除文件中某一行

将文本中的 tasting123删除 
with open("fileread.txt","r",encoding="utf-8") as f:
    lines = f.readlines()
    #print(lines)
with open("fileread.txt","w",encoding="utf-8") as f_w:
    for line in lines:
        if "tasting123" in line:
            continue
        f_w.write(line)

实际是文件内容重写

上一篇:Number of lines annotated by Git is not equal to number of lines in the file, check file encoding an


下一篇:原本的变量名处在变量值的位置,如何重新提取变量名