📌  相关文章
📜  使用 write() 函数向文本文件追加一行 - Python 代码示例

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

代码示例1
# Program to append to text file using write() function
with  open("python.txt", "a") as file:
    content = "Append the content at the end \n"
    file.write(content)
    file.close()


# Program to read the entire file (absolute path) using read() function
with open("C:/Projects/Tryouts/python.txt", "r") as file:
    content = file.read()
    print(content)
    file.close()