Commit 9b24e26c by BellCodeEditor

save project

parent b7515265
Showing with 3 additions and 3 deletions
...@@ -9,10 +9,10 @@ with open(r'C:\Users\yoyo\Desktop\bellcode.txt','a',encoding='utf-8')as filel: ...@@ -9,10 +9,10 @@ with open(r'C:\Users\yoyo\Desktop\bellcode.txt','a',encoding='utf-8')as filel:
filel.write('小兰:12本\n') filel.write('小兰:12本\n')
for data in filel: for data in filel:
if '李文:9本' in data: if '李文:9本' in data:
print('李文数据在文件中') data=data.replace('李文:9本','李文:10本')
if '张伟:16本'in data: if '张伟:16本'in data:
print('张伟数据在文件中') data=data.replace('张伟:16本','张伟:15本')
new_data+=data new_data +=data
with open(r'C:\Users\yoyo\Desktop\bellcode.txt','w',encoding='utf-8')as filel: with open(r'C:\Users\yoyo\Desktop\bellcode.txt','w',encoding='utf-8')as filel:
filel.write(new_data) filel.write(new_data)
......
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