Python簡易版圖書管理系統(tǒng)
本文實(shí)例為大家分享了python圖書管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
"""
圖書管理系統(tǒng)
"""
import random
# books={書名:剩余數(shù)量, 書名:剩余數(shù)量}
import time
books = {"防脫發(fā)指南": 5, "頸椎康復(fù)指南": 3, "從刪庫到跑路": 0}
# students_books=[name,{書}]
students_books = {"趙路遙": []}
class book(object):
"""先傳一個(gè)書名,以后可根據(jù)需要傳 開始借書時(shí)間,書的詳細(xì)信息,以及之前借書的人等等"""
def __init__(self, bookname):
super(book, self).__init__()
self.bookname = bookname
def getBookName(self):
return self.bookname
if __name__ == "__main__":
print("*" * 50)
print("歡迎來到遙遙哥的圖書館".center(50))
print("*" * 50)
while True:
choices = input(""" 請(qǐng)選擇你所需要的功能
1.查詢書籍 2.借書 3.還書 4.顯示所有書籍 5.查詢用戶所借的書 6.退出系統(tǒng):""")
if choices == '1':
# 查詢書籍
print('--------查詢書籍---------')
search_book = input('請(qǐng)輸入要查詢的書籍名稱:')
# 遍歷books
for book in books.keys():
if search_book in book:
print("正在查找,請(qǐng)稍等")
time.sleep(1)
if books[search_book] > 0:
print("你說查找的書,目前還有{}本".format(books[search_book]))
break
else:
print("你所查找的書,已經(jīng)借完,請(qǐng)過段時(shí)間之后再來")
break
else:
print("對(duì)不起你所輸入的書不存在,可聯(lián)系管理員補(bǔ)充")
elif choices == '2':
# 借書
print("歡迎來到借書頁面".center(50))
flag = True
while flag:
user_name = input("請(qǐng)輸入用戶名")
borrow_book = input("請(qǐng)輸入你所借的書名")
for book in books.keys():
if borrow_book == book:
if user_name in students_books.keys():
if books[borrow_book] > 0:
if borrow_book not in students_books[user_name]:
print(r"你已經(jīng)借書<<{}>>".format(borrow_book))
students_books[user_name].append(borrow_book)
books[borrow_book] -= 1
print(r"現(xiàn)在<<{}>>,剩余{}本".format(borrow_book, books[borrow_book]))
flag = False
break
else:
print("對(duì)不起,你已經(jīng)借了一本")
flag = False
break
else:
print("對(duì)不起你所借的書剩余{}本,請(qǐng)下次再來".format(books[borrow_book]))
flag = False
break
else:
students_books[user_name] = []
students_books[user_name].append(borrow_book)
books[borrow_book] -= 1
print(r"新用戶( {} )已經(jīng)借書<< {} >>,目前此書剩余{}本".format(user_name, borrow_book, books[borrow_book]))
flag = False
break
else:
print("對(duì)不起你所查找的書,不存在,請(qǐng)聯(lián)系管理員更新")
elif choices == '3':
flag=True
while flag:
user_name = input("請(qǐng)輸入你的名字")
repay_book = input("情輸入你所要還的書")
for name in students_books.keys():
#先去判斷有沒有這個(gè)人
if name==user_name:
#判斷有沒有這本書在不在該用戶
if repay_book in students_books[name]:
#判斷此本書書否在圖書館庫里面
if repay_book in books.keys():
books[repay_book]+=1
students_books[name].remove(repay_book)
print("正在還書,請(qǐng)稍等")
time.sleep(1)
print("你已經(jīng)還書了,這本書數(shù)量為{}".format(books[repay_book]))
flag=False
break
else:
print("此本書不在圖書館庫里面,請(qǐng)重新輸入")
break
else:
print("你所輸入的書,并在你的借書目錄里面,請(qǐng)重新輸入")
break
else:
print("對(duì)不起你所輸入的人不存在,請(qǐng)重新輸入")
elif choices == '4':
# 顯示所有書籍
print("圖書館目前所藏書籍如下:")
for bookkey, bookvalue in list(books.items()):
print(r"<<{}>>目前還有 {} 本".format(bookkey, bookvalue))
time.sleep(0.5)
elif choices=='5':
username=input(" 請(qǐng)輸入你要查詢的用戶名")
for stu in students_books.keys():
if username== stu:
print("{}所借的書有{}".format(user_name,students_books[username]))
else:
print("你查找的用戶不在")
elif choices == '6':
choice = ("確定是否退出,確認(rèn)請(qǐng)輸入yes,否則請(qǐng)輸入no")
if choice == 'yes':
print("感謝你的使用,再見")
break
else:
print('輸入錯(cuò)誤請(qǐng)重新輸入....')
更多學(xué)習(xí)資料請(qǐng)關(guān)注專題《管理系統(tǒng)開發(fā)》。
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- python實(shí)現(xiàn)簡易圖書管理系統(tǒng)
- python編寫圖書管理系統(tǒng)
- Python實(shí)現(xiàn)簡易的圖書管理系統(tǒng)
- Python實(shí)現(xiàn)圖書借閱管理系統(tǒng)
- Python實(shí)現(xiàn)圖書管理系統(tǒng)設(shè)計(jì)
- 基于python實(shí)現(xiàn)圖書管理系統(tǒng)
- python代碼實(shí)現(xiàn)圖書管理系統(tǒng)
- python實(shí)現(xiàn)簡單圖書管理系統(tǒng)
- python面向?qū)ο蠓▽?shí)現(xiàn)圖書管理系統(tǒng)
- wxpython實(shí)現(xiàn)圖書管理系統(tǒng)
- python圖書管理系統(tǒng)
- python實(shí)現(xiàn)圖書管理系統(tǒng)
- python模擬實(shí)現(xiàn)圖書管理系統(tǒng)
相關(guān)文章
Python實(shí)現(xiàn)字典的key和values的交換
本文給大家分別介紹了在python3.0和2.7版本下實(shí)現(xiàn)字典的key和values的交換的程序代碼,非常的簡單實(shí)用,有需要的小伙伴可以參考下。2015-08-08
一行代碼解決動(dòng)態(tài)執(zhí)行Python函數(shù)方法實(shí)例
這篇文章主要為大家介紹了如何用一行代碼解決動(dòng)態(tài)執(zhí)行Python函數(shù)方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12
Python 用三行代碼提取PDF表格數(shù)據(jù)
這篇文章主要介紹了Python 用三行代碼提取PDF表格數(shù)據(jù),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
Python寫的Discuz7.2版faq.php注入漏洞工具
這篇文章主要介紹了Python寫的Discuz7.2版faq.php注入漏洞工具,全自動(dòng)的一款注入工具,針對(duì)Discuz7.2版,需要的朋友可以參考下2014-08-08
圖文詳解Django使用Pycharm連接MySQL數(shù)據(jù)庫
這篇文章主要介紹了Django使用Pycharm連接MySQL數(shù)據(jù)庫的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-08-08
基于Python實(shí)現(xiàn)文本文件轉(zhuǎn)Excel
Excel文件是我們常用的一種文件,在工作中使用非常頻繁。Excel中有許多強(qiáng)大工具,因此用Excel來處理文件會(huì)給我們帶來很多便捷。本文就來和大家分享一下Python實(shí)現(xiàn)文本文件轉(zhuǎn)Excel的方法,感興趣的可以了解一下2022-08-08

