From 9048d56a61a0508b55cf0f7a0470c4924a20219f Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Fri, 2 Jun 2023 20:16:45 +0800 Subject: [PATCH] save project --- diy.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 diy.py diff --git a/diy.py b/diy.py new file mode 100644 index 0000000..049fcda --- /dev/null +++ b/diy.py @@ -0,0 +1,12 @@ +# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' +with open(r'C:\Users\windows\Desktop\捐赠.txt',"w",encoding = 'utf-8') as f: + f.write("小兰:12本\n") + f.write("小丽:11本\n") + f.write("李文:9本\n") + f.write("张伟:16本\n") + f.write("俞老师:12本\n") + +with open(r'C:\Users\windows\Desktop\捐赠.txt',"r",encoding = 'utf-8') as f: + for data in f: + if "小丽:11本" in data: + print("数据在文件中") -- libgit2 0.25.0