From 78430efc8bc5b1ad9690f22a49b0618b8aa84f32 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 3 Dec 2022 14:10:10 +0800 Subject: [PATCH] auto save --- diy.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/diy.py b/diy.py index 73f4492..5224e6a 100644 --- a/diy.py +++ b/diy.py @@ -1 +1,11 @@ # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' + #路径 模式 编码格式 + +file1=open(r"C:\Users\Administrator\Desktop\book.txt","w",encoding="utf-8") +file1.write('张伟:12本\n') +file1.write('李文:11本\n') +file1.close() + + +with open(r"C:\Users\Administrator\Desktop\book.txt","a",encoding="utf-8") as file1: + file1.write('悟空:92本\n') \ No newline at end of file -- libgit2 0.25.0