📌  相关文章
📜  python 从文件中读取和删除行 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:18.095000             🧑  作者: Mango

代码示例1
with open("yourfile.txt", "r") as f:
    lines = f.readlines()
with open("yourfile.txt", "w") as f:
    for line in lines:
        if line.strip("\n") != "nickname_to_delete":
            f.write(line)