From b5aa826d3ba43269d0a42485f754482d68aa335d Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 2 Nov 2024 11:04:02 +0800 Subject: [PATCH] save project --- diy.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 diy.py diff --git a/diy.py b/diy.py new file mode 100644 index 0000000..d552a33 --- /dev/null +++ b/diy.py @@ -0,0 +1,10 @@ +# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' +new_data='' +with open(r'D:\麻xr\a.txt','r',encoding='utf-8')as book: + for data in book: + if '小明:10本' in data: + data=data.replace('小明:10本','小明:1本') + new_data+=data + +with open(r'D:\麻xr\a.txt','w',encoding='utf-8')as book: + book.write(new_data) \ No newline at end of file -- libgit2 0.25.0