Commit 815734a6 by BellCodeEditor

save project

parent 1ed56310
Showing with 7 additions and 3 deletions
...@@ -5,9 +5,13 @@ ...@@ -5,9 +5,13 @@
# file1.write('小方:5本') # file1.write('小方:5本')
# file1.write('小高:20本') # file1.write('小高:20本')
# file1.close() # file1.close()
with open(r'C:\users\CM\Desktop\test.txt','r',encoding='utf-8')as with open(r'C:\users\CM\Desktop\test.txt','r',encoding='utf-8') as file1:
file: for data in file1:
a=file.read('小兰:12本') if'小兰:12本' in data:
print('数据在文件中')
file1.write('小兰:12本')
a=file.read()
print(a) print(a)
......
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