Commit ea4275c0 by BellCodeEditor

save project

parent d3e6f232
Showing with 7 additions and 0 deletions
...@@ -8,3 +8,9 @@ file.close() ...@@ -8,3 +8,9 @@ file.close()
with open(r"C:\Users\Administrator\Desktop\book.txt",'a',encoding='utf-8') as file: with open(r"C:\Users\Administrator\Desktop\book.txt",'a',encoding='utf-8') as file:
file.write('小强:12本\n') file.write('小强:12本\n')
file.write('小明:15本\n') file.write('小明:15本\n')
with open(r"C:\Users\Administrator\Desktop\book.txt",'r',encoding='utf-8') as file:
for i in file:
if '小强:12本\n' in i:
print("小强捐了12本")
if '小兰:12本\n' in i:
print("小兰捐了12本")
\ 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