Commit ffc6228e by BellCodeEditor

save project

parent 3d5ffb08
Showing with 11 additions and 2 deletions
...@@ -6,7 +6,16 @@ file.close() ...@@ -6,7 +6,16 @@ file.close()
#with open(r'C:\Users\玛酷机器人\Desktop\test.txt",'a', encoding='utf-8') as file: #with open(r'C:\Users\玛酷机器人\Desktop\test.txt",'a', encoding='utf-8') as file:
#file.write('任科洁:13本') #file.write('任科洁:13本')
#file.write('李明:12本') #file.write('李明:12本')
#with open(r"C:\Users\玛酷机器人\Desktop\test.txt",'r', encoding='utf-8') as file:
#for data in file:
#if '任科洁:13本'in data:
#print('数据在文件中 ')
e_data=""
with open(r"C:\Users\玛酷机器人\Desktop\test.txt",'r', encoding='utf-8') as file: with open(r"C:\Users\玛酷机器人\Desktop\test.txt",'r', encoding='utf-8') as file:
for data in file: for data in file:
if '任科洁:13本'in data: if '任科洁:13本'in data:
print('数据在文件中 ') data=data.replace('任科洁:13本','李明:12本')
\ No newline at end of file e_data+=data
with open(r"C:\Users\玛酷机器人\Desktop\test.txt",'w', encoding='utf-8') as file:
file.write(e_data)
\ 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