資源簡介
主要利用python的類進行編寫,基于pytho的圖書館管理系統具有增加圖書,查找圖書,歸還圖書等功能
原參考地址為:https://blog.csdn.net/jay_youth/article/month/2018/05
代碼片段和文件信息
class?Book(object):
def?__init__(selfnameauthorcountbookindex):
self.name=name
self.author=author
self.count=count
self.bookindex=bookindex
def?__str__(self):
return?“書名:《%s》?作者:<%s>?數量:<%s>?位置:<%s>“?%?(self.name?self.author?self.count?self.bookindex)
class?indentity(object):
StudentDict={‘yu‘:‘123‘‘yang‘:‘456‘‘wang‘:‘789‘}
@staticmethod
def?Choice_id():
choice=str(input(“請選擇:【1】學生登陸\n【2】注冊新用戶“))
if?choice==‘1‘:
indentity.StudentIdentity()
elif?choice==‘2‘:
name=str(input(“請輸入你的姓名:“))
code=str(input(“請輸入你的密碼:“))
indentity.StudentDict[name]=code
print(“注冊成功“)
indentity.StudentIdentity()
else:
print(“您輸入的有誤“)
indentity.Choice()
@classmethod
def?StudentIdentity(cls):
username=str(input(“請輸入你的姓名“))
password=str(input(“請輸入你的密碼“))
for?key?in?cls.StudentDict:
if?(key==username?and?cls.StudentDict[key]==password):
print(“歡迎進入圖書管理系統“)
Menu.StudentMnue()
print(“你的身份不正確,請重新輸入“)
cls.StudentIdentity()
class?Menu(object):
@staticmethod
def?StudentMnue():
print(“[1]查看藏書\n“)
print(“[2]借閱圖書\n“)
print(“[3]歸還圖書\n“)
print(“[4]增加書籍\n“)
print(“[5]查找書籍\n“)
print(“[0]退出系統\n“)
while?True:
studentchoice=str(input(“請選擇:“))
if?studentchoice==‘1‘:
Choice.StudentSee()
elif?studentchoice==‘2‘:
Choice.StudentBorrow()
elif?studentchoice==‘3‘:
Choice.StudentGive()
elif?studentchoice==‘4‘:
Choice.add_book()
elif?studentchoice==‘5‘:
Choice.book_find()
elif?studentchoice==‘0‘:
break
else:
print(“您輸入的不正確“)
global?Booklistbook
Booklist=[]
class?Choice(object):
@staticmethod
def?add_book():
global?book
name=str(input(“請輸入書籍名稱:“))
author=str(input(“請輸入書籍作者:“))
count=input(“請輸入書籍數量:“)
bookindex=str(input(“請輸入書籍編號:“))
book=Book(name?author?count?bookindex)
Booklist.append(book)
print(“添加書籍成功“)
Choice.StudentSee()
@staticmethod
def?book_find():
name=input(“請輸入書籍:“)
for?book?in?Booklist:
if?name==book.name:
print(“《%s》?作者:%s??數量:%s??樓層:%s!“?%(book.namebook.authorbook.countbook.bookindex))
return?book
elif?name!=book.name:
continue
else:
print(“《%s》沒有找到!“?%name)
return?None
@staticmethod
def?S
- 上一篇:python實現多項式加減乘除
- 下一篇:python turtle繪圖
評論
共有 條評論