Commit 8600fb26 by BellCodeEditor

save project

parent c363bf03
Showing with 12 additions and 3 deletions
...@@ -6,9 +6,17 @@ ...@@ -6,9 +6,17 @@
# jj.write("张伟:16本") # jj.write("张伟:16本")
# jj.close() # jj.close()
with open(r"C:\Users\123\Desktop\新建文件夹\book.txt","r""utf-8") as jj: with open(r"C:\Users\123\Desktop\新建文件夹\book.txt","r""utf-8") as jj:
for i in jj: for data in jj:
if '小兰:12本' in i: if '小强:12本' in data:
print("数据在文件中") data=data.replace('小强:12本','小强:11本')
new_data+=data
with open(r"C:\Users\123\Desktop\新建文件夹\book.txt","w""utf-8") as jj:
jj.write(new_data)
vwith open(r"C:\Users\123\Desktop\新建文件夹\book.txt","r""utf-8") as jj:
a=jj.read()
print(a)
# jj.write("小强:12本") # jj.write("小强:12本")
# jj.write("李明:15本") # jj.write("李明:15本")
# jj.close() # jj.close()
\ 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