Commit 9ad60092 by BellCodeEditor

save project

parent 101f8dbf
Showing with 9 additions and 6 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
new_date = ""
with open(r"C:\Users\Windows 10\Desktop\book.txt","r",encoding="utf-8") as file: with open(r"C:\Users\Windows 10\Desktop\book.txt","r",encoding="utf-8") as file:
a = file.read() for date in file:
for date in a: if "小强:12本" in date:
if "小强:10本" in date: date.replace("小强:12本","小强:11本")
print("yes1")
if "小兰:12本" in date: if "小兰:12本" in date:
print("yes2") date.replace("小兰:12本","小兰:14本")
\ No newline at end of file new_date += date
with open(r"C:\Users\Windows 10\Desktop\book.txt","w",encoding="utf-8") as file:
file.write(new_date)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment