Commit 6135c141 by BellCodeEditor

save project

parent a8d02629
Showing with 22 additions and 0 deletions
# file1=open(r"C:\Users\Administrator\Desktop\diy1.txt","r",encoding='utf-8')
# a=[file1.read()]
# for i in a:
# if '小强' in i:
# print('在文件中')
# file1.close()
with open(r"C:\Users\Administrator\Desktop\diy1.txt",'r',encoding='utf-8') as file1:
a=[file1.read()]
for i in a:
if '小强' in i:
print('在文件中')
i=i.replace('小强:12本','小强:11')
iii=i
for w in a:
if '小丽' in i:
print('在文件中')
w=w.replace('小丽:12本','小丽:14本')
www=w
with open(r"C:\Users\Administrator\Desktop\diy1.txt",'w',encoding='utf-8') as file1:
file1.write(iii)
file1.write(www)
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