Commit 27ac8ab5 by BellCodeEditor

save project

parent dc22b1a3
Showing with 31 additions and 0 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
f=open(r"C:\Users\vvjkkjs\Desktop\book.txt","w",encoding="utf8")
f.write("""小兰:12本
小丽:11本
李文:9本
张伟:16本""")
f.close()
\ No newline at end of file
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
f=open(r"C:\Users\vvjkkjs\Desktop\book.txt","w",encoding="utf8")
f.write("""小兰:12本
小丽:11本
李文:9本
张伟:16本
小强:12本
李明:15本""")
##李明:15本""")
f.close()
f=open(r"C:\Users\vvjkkjs\Desktop\book.txt","r",encoding="utf8")
for each in f.readlines():
if "小强:10本"in each:
print("小强在数据中")
else:
print("小强不在数据中")
if "小兰:12本"in each:
print("小兰在数据中")
break
else:
print("小兰不在数据中")
break
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