|
print("*"*50)
print("图书管理系统")
print("1--查找图书")
print("2--借阅图书")
print("3--归还图书")
print("4--显示所有图书")
print("5--退出系统")
print("*"*50)
books = [
{"名称":"python","数量":10},
{"名称":"java","数量":10},
{"名称":"js","数量":10},
{"名称":"css","数量":10}
]
while True:
modle = int(input("请输入你的选择序号"))
if modle == 1:
#print("1--查找图书")
book_name = input("请输入你要查找的书名")
for book in books:
if book_name == book["名称"]:
print("恭喜你查找到-->",book)
break
else:
print('本图书馆没有查找到你搜索的书名-->',book_name)
elif modle == 2:
book_name = input("请输入你要借阅图书")
for book in books:
if book_name == book["名称"] and book["数量"] > 0:
print("恭喜你借阅成功-->",book_name)
book["数量"] -= 1
break
else:
print('本图书馆没有查找到你搜索的书名-->',book_name)
elif modle == 3:
print("3--归还图书")
book_name = input("请输入你要归还的图书")
for book in books:
if book_name == book["名称"]:
book["数量"] += 1
break
else:
books.append({"名称":book_name})
print("归还成功")
elif modle == 4:
for item in books:
print(item)
print("4--显示所有图书")
elif modle == 5:
print("5--退出系统")
break
else:
print("输入有误,请重新输入")
总结:感觉python代码还是比较简洁大气,一定要坚持学习下去我相信以后能成为大神的哈哈
|
|