Commit acb03cf5 by BellCodeEditor

save project

parent e2c407d9
Showing with 13 additions and 5 deletions
......@@ -5,12 +5,20 @@
# a.write('\n李文:9本')
# a.write('\n张伟:16本')
# a.close()
with open(r"C:\Users\EDZ\Desktop\tiancai.txt","a",encoding="utf-8") as a:
c=""
with open(r"C:\Users\EDZ\Desktop\tiancai.txt","r",encoding="utf-8") as a:
# a.write('\n小兰:12本')
# a.write('\n小丽:11本')
# a.write('\n李文:9本')
# a.write('\n张伟:16本')
for i in a:
b=a.read()
if '小兰:12本' in b:
print("在里面")
\ No newline at end of file
if '小兰:12本' in b:
b.replace('小兰:12本','小兰:10本')
c=b
with open(r"C:\Users\EDZ\Desktop\tiancai.txt","w",encoding="utf-8") as a:
a.write(c)
with open(r"C:\Users\EDZ\Desktop\tiancai.txt","w",encoding="utf-8") as a:
d=a.read()
print(d)
\ 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