From e478331bdf238c9c3311decba02d62998d3e8f40 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 23 May 2021 19:31:00 +0800 Subject: [PATCH] save project --- diy.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 diy.py diff --git a/diy.py b/diy.py new file mode 100644 index 0000000..fd84aaa --- /dev/null +++ b/diy.py @@ -0,0 +1,22 @@ +# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' +# file = open(r'C:\Users\栩栩\Desktop\toony.txt','w',encoding = "utf-8") +# file.write('小兰,12本\n') +# file.write('小丽,11本\n') +# file.write('李文,9本\n') +# with = open(r'C:\Users\栩栩\Desktop\toony.txt','w',encoding = "utf-8") as file: +# f.write("小兰:12本\n") +# with = open(r'C:\Users\栩栩\Desktop\toony.txt','w',encoding = "utf-8") as file: +# for i in file(3): +# if '小兰:12本'in i: +# print("在里面") +# else: +# print("不在") +x='' +with open(r'C:\Users\栩栩\Desktop\toony.txt','r',encoding = "utf-8") as file: + for i in file: + if '小兰:12本'in i: + i.repiace('小兰,12本','小兰,14本') + print(i) + x=x+i +with open(r'C:\Users\栩栩\Desktop\toony.txt','w',encoding = "utf-8") as file: + file.write(x) -- libgit2 0.25.0