In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.