Python Lite library management system

"" "
Library management system
" ""
Import Random

# Books = {Title: remaining number, Title: Number of remaining}
Import Time

books = { "anti-hair loss Guide": 5 "Rehabilitation cervical Guide": 3, "Library deleted from the foot to": 0}
# students_books = [name, {book}]
students_books = { "Zhao Lu Yao": [ ]}


Book class (Object):
"" "first pass a title, after the library may need to pass the start time, details of the book, as well as people before the library, and so on according to" ""

def __init__(self, bookname):
super(book, self).__init__()
self.bookname = bookname

def getBookName(self):
return self.bookname


__name__ == IF "__main__":
Print ( "*" * 50)
Print ( "Welcome to the library distant brother" .center (50))
Print ( "*" * 50)
the while True:
choices = the INPUT ( " "" Please select the function you need
1. query library books 2. 3. 4. the book also shows all user queries borrowed books 5 book 6. exit the system: "" ")
IF == choices '1' :
# query books
print ( '-------- queries books ---------')
search_book the iNPUT = ( 'Please enter the name of the book you want to query:')
# traversing Books
for book in Books .keys ():
IF search_book in book:
print ( "are looking for, please wait")
the time.sleep (1)
IF books [search_book]> 0:
book print ( "you say looking for, there are still {this} ".format (books [search_book]))
BREAK
the else:
Print (" the book you're looking for, already borrowed finished, please come over after a period of time. ")
BREAK
the else:
Print ( "I'm sorry the book you entered does not exist, you can contact the administrator complement")

== choices elif '2':
# library
print ( "Welcome to the library page" .center (50))
Flag = True
the while Flag:
user_name = the INPUT ( "Please enter your user name")
borrow_book the INPUT = ( "Please enter your borrowed title ")
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 "you've library {} >> <<" the format (borrow_book).)
students_books [USER_NAME] .append (borrow_book)
Books [borrow_book] - =. 1
print (r "} {<< >> now, the remaining {} this ".format (borrow_book, Books [borrow_book]))
In Flag = False
BREAK
the else:
Print (" Sorry, you have a borrowed ")
flag = False
break
else:
print ( "Sorry you borrowed book {} remaining present, please return to" .format (Books [borrow_book]))
In Flag = False
BREAK
the else:
students_books [USER_NAME] = []
students_books [USER_NAME] .append (borrow_book)
Books [borrow_book] - =. 1
Print (R & lt "new user ({})} >> {<< library has, the remaining {} this has the book" .format (USER_NAME, borrow_book, Books [borrow_book]))
In Flag = False
BREAK

the else:
Print ( "I'm sorry the book you are looking for does not exist, please contact the administrator update")

== choices elif '3':
Flag = True
the while Flag:
user_name = the INPUT ( "Please enter your name")
repay_book the INPUT = ( "Enter the love you have to repay the book")
for name in students_books.keys ():
# go to the judge there is no such person
IF name == user_name:
# there is no judgment in this book is not in the user
IF repay_book in students_books [name]:
# judge this book is no book in the library inside the library
if repay_book in books.keys ():
books [repay_book] + = 1
students_books [name] .remove (repay_book)
Print ( "the book return, please wait")
the time.sleep (1)
Print ( "you have to return the book, and the book number } to { "format (books [repay_book])).
Flag = False
BREAK
the else:
Print (" this book is not in the library inside the library, please re-enter ")
BREAK
the else:
Print (" the book you entered, and your library directory, please re-enter ")
break
the else:
Print ( "I'm sorry people you entered does not exist, please re-enter")

== choices elif '. 4':
# Show all books
print ( "currently hidden library books as follows:")
for BookKey, bookvalue in List (books.items ()):
Print (R & lt "<< >> {now} {} also present ".format (BookKey, bookvalue))
the time.sleep (0.5)
elif choices == '. 5':
username = iNPUT (" Please enter your user name to query ")
for STU in students_books.keys ( ):
IF username == STU:
Print ( "{} borrowed book has} {" the format (USER_NAME, students_books [username].))
the else:
Print ( "you are looking for is not the user")
elif choices == '. 6 ':
Choice = ( "to determine whether to exit, confirm enter yes, otherwise, enter NO")
iF Choice ==' yes ':
Print ( "thank you for your use, goodbye")
BREAK
the else:
Print (' re-entry errors input .... ')

Guess you like

Origin www.cnblogs.com/liyanyan665/p/11332648.html