Commit 14331169 by BellCodeEditor

save project

parent 14ba73e5
Showing with 1 additions and 14 deletions
......@@ -7,19 +7,6 @@
# filel.write('小强:12本\n')
# filel.write('李明:15本\n')
# filel.close()
#with open(r"C:\Users\mayi_robot\Desktop\test.txt",'r',encoding='utf-8') as filel:
# a = filel.read()
# print(a)
newb=''
with open(r"C:\Users\mayi_robot\Desktop\test.txt",'r',encoding='utf-8') as filel:
for b in filel:
if '小强:12本'in b:
b=b.replace('小强:12本','小强:11本')
if '小兰:12本'in b:
b=b.replace('小兰:12本','小兰:14本')
newb+=b
with open(r"C:\Users\mayi_robot\Desktop\test.txt",'w',encoding='utf-8') as filel:
filel.write(newb)
with open(r"C:\Users\mayi_robot\Desktop\test.txt",'r',encoding='utf-8') as filel:
a=filel.read()
a = filel.read()
print(a)
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