Commit bfeef8ad by BellCodeEditor

save project

parent 9a602a9f
Showing with 6 additions and 4 deletions
sb=open(r"C:\Users\CDLX\Desktop\book1.txt","w",encoding="utf-8") sb=open(r"C:\Users\CDLX\Desktop\book1.txt","w",encoding="utf-8")
sb.write("小兰12本\n") sb.write("小兰:12本\n")
sb.write("小丽:11本\n") sb.write("小丽:11本\n")
sb.write("李文:9本\n") sb.write("李文:9本\n")
sb.write("张伟:16本\n") sb.write("张伟:16本\n")
sb.close() sb.close()
with open(r"C:\Users\CDLX\Desktop\book1.txt","a",encoding="utf-8") as bs: with open(r"C:\Users\CDLX\Desktop\book1.txt","a",encoding="utf-8") as bs:
bs.write("小强:10本") bs.write("小强:10本\n")
bs.write("李明:15本") bs.write("李明:15本\n")
with open(r"C:\Users\CDLX\Desktop\book1.txt","r",encoding="utf-8") as bs: with open(r"C:\Users\CDLX\Desktop\book1.txt","r",encoding="utf-8") as bs:
for i in bs: for i in bs:
if "小强:10本" in bs: if "小强:10本" in i:
print("sb") print("sb")
if "小兰:12本" in i:
print("bs")
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