Commit 6a65c01c by BellCodeEditor

save project

parent bc719281
Showing with 15 additions and 4 deletions
...@@ -7,7 +7,18 @@ ...@@ -7,7 +7,18 @@
#file=open(r"C:\Users\EDY\Desktop\伏地魔.txt",'a',encoding='utf-8') #file=open(r"C:\Users\EDY\Desktop\伏地魔.txt",'a',encoding='utf-8')
#file.write('小明:1本\n') #file.write('小明:1本\n')
#file.close() #file.close()
new_data=''
with open(r"C:\Users\EDY\Desktop\伏地魔.txt",'r',encoding='utf-8') as file1:
for data in file1:
if '小强:10本'in data:
data=data.replace('小强:12本','小强:14本')
if '小兰:12本'in data:
data=data.replace('小兰:12本','小兰:14本')
new_data +=data
with open(r"C:\Users\EDY\Desktop\伏地魔.txt",'w',encoding='utf-8') as file:
file1.write(new_data)
with open(r"C:\Users\EDY\Desktop\伏地魔.txt",'r',encoding='utf-8') as file: with open(r"C:\Users\EDY\Desktop\伏地魔.txt",'r',encoding='utf-8') as file:
for i in file: a=file1.read()
if "小明:1本" in i: print(a)
print("该数据在里面") \ No newline at end of file
\ 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