In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use Python to help the school write a book management system. Many people may not know much about it. In order to let everyone know more, Xiaobian summarized the following contents for everyone. I hope everyone can gain something according to this article.
Not much to say, direct text began, saying just eat a meal is not a loss, is not a bonus did not give me!
Simple implementation of library management system
Classes and object-oriented programming
"Small clock library management system 1. Enquiry 2. increased by 3. Borrowing 4. Return 5. Exit """
class Book(object): def __init__(self,name,author,state,book_position): self.name = name self.author = author self.state = state #Judge book status 0: lent 1: not lent self.book_position = book_position #str (object) is automatically called when printing objects def __str__(self): return f"Title: {self.name}, Author: , Status: , Location: "def directory(self): self.start() while True: print("""Xiaozhong Library Management System: 1. Enquiry 2. increased by 3. Borrowing 4. Return 5. exit """) chioce = int(input(" Enter the action you want:")) if chioce == 1: name = input(" You want to query the title of the book: ") self.checkBook(name) elif chioce == 2: self.addBook() elif chioce == 3: self.BorrowBook() elif chioce == 4: self.return_book() elif chioce == 5: print(" Exit the system! ") break else: print(" Your input is incorrect, please re-enter! ") #Add book def addBook(self): name = input(" Title of book to be added: ") self.books.append(Book(name,input(" Author: "),1,input(" Position: "))) print(f" Book {name} added successfully! ") #Borrowing def BorrowBook(self): name = input(" Borrowed Book Name: ") Books = self.checkBook(name) #Determine the status of the book if Books != None: if Books.state == 0: print(f"Book {name} has been loaned! ") elif Books.state == 1: print(f" Book {name} borrowed successfully! ") Books.state = 0 else: print(f" Book {name} does not exist! ") #return books def return_book(self): name = input(" return book name: ") Books = self.checkBook(name) if Books != None : if Books.state == 1: print(f"Book {name} has been loaned! ") elif Books.state == 0: print(f" Book {name} returned successfully! ") Books.state = 1 else: print(f" Book {name} is inconsistent with the one lent! ") def checkBook(self,name): " Find out if a book exists " for book in self.books: # book: objects created by Book class if book.name == name: print(book) return book else: return print(f" The book {name} you are looking for is not in the system! Please re-enter! ") book_Manag = Book_Manag() book_Manag.directory() After reading the above, do you have any further understanding of how to write a library management system for schools in Python? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.
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.