In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to realize the library lending system with python". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to realize the library lending system with python".
I hope this simple procedure can do this:
The code is as follows:
Class Book: def _ _ init__ (self,name,author,recommend State=0): self.name= name self.author= author self.recommend= recommend self.state= state def _ str__ (self): if self.state==0: status=' not lent 'elif self.state==1: status=' lent' return 'name:% s' author:% s recommendation:% s status:% s'% (self.name,self.author) Self.recommend,status) class BookManager: books= [] def check_book (self,name): for book in self.books: if book.name = = name: return book else: return None def _ init__ (self): book1 = Book ('fear record', 'Fernando Pessoa', 'self-revelation of a soul lost and on the verge of collapse A hymn to obscurity, failure, wisdom, difficulty and silence. Book2 = Book ('take the arrow as the wing', 'Jianyu', 'reconcile the ethereal style of writing and the Zen realm, depict the origin and extinction of the human world. Like a flexible rope, the word love hurts the hearts of many people.') Book3 = Book ('the heart is a lonely hunter', 'Carson McCullers','We longed to talk, but we never listen.' , 1) self.books.append (book1) self.books.append (book2) self.books.append (book3) def manu (self): print ('Welcome to the wandering library management system, every good book of silence is a wandering island. I hope you have the chance to find and land and find a habitat for your spiritual home. \ n') while True: choice = int (input) Welcome to our library lending system! Please select the service you need: 1. Query all books 2. Add Book 3. Borrow books 4. Return books 5. To exit the system, enter a number to select the corresponding function:'') if choice = = 1: self.show_all_book () # display the information of each book elif choice = = 2: self.add_book () elif choice = = 3: self.lend_book () # borrow books elif choice = = 4: self.return_book () # return books elif choice = = 5: print ('Thank you for using this system Learning is boundless, I wish you success!') Break def show_all_book (self): for book in self.books: print (book) def add_book (self): new_name = input ('Please enter the name of the book:') new_author = input ('please enter the author's name:') new_comment = input ('Please enter the book recommendation:) # get the corresponding information about the book Assign a value to the attribute new_book = Book (new_name, new_author, new_comment) # pass in parameters, create an instance of Book class new_book self.books.append (new_book) # add new_book to the list books print ('book input successful! \ n') def lend_book (self): borrow_name = input ('Please enter the name of the book:') res = self.check_book (borrow_name) if resurgent books none: if res.state = 1: print ('the book has been lent out Come back next time') else: print ('you can borrow a book') res.state = = 1 else: print ('there is no such book in the library') def return_book (self): return_name = input ('Please enter the book name:') res = self.check_book (return_name) if resurgent books none: if res.state = = 0: print ('this book is not lent out yet!') Else: print ('return successful!') Else: print ('this library does not have this book') manager = BookManager () manager.manu () so far, I believe you have a deeper understanding of "how to implement the library lending system in python". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.