库存管理系统代码python
时间: 2023-11-16 20:56:40 浏览: 55
很抱歉,根据提供的引用内容,没有提到库存管理系统代码的Python实现。引用内容提到的是医院挂号系统的Python实现,使用了MySQL数据库进行程序开发。该系统包括管理员、病人和医生三个角色,管理员可以进行个人中心、病人管理、医生管理、科室类型管理、科室信息等功能。同时,引用提到了一个工具,可以用于确认管理密码和数据库生成的地址,以确保程序的正常运行。
相关问题
商品库存管理系统python
以下是一个简单的商品库存管理系统的Python代码示例:
```python
class Product:
def __init__(self):
self.name = input('请输入商品名称:')
self.price = float(input('请输入商品价格:'))
self.index = input('请输入商品编码:')
self.number = int(input('请输入商品数量:'))
def __str__(self):
return '商品名称:{},商品价格:{},数量:{},商品编码:{}'.format(self.name, self.price, self.number, self.index)
# 创建商品列表
products = []
# 添加商品
def add_product():
product = Product()
products.append(product)
print('商品添加成功!')
# 查看商品列表
def view_products():
if len(products) == 0:
print('商品列表为空!')
else:
for product in products:
print(product)
# 删除商品
def delete_product():
index = input('请输入要删除的商品编码:')
for product in products:
if product.index == index:
products.remove(product)
print('商品删除成功!')
return
print('未找到该商品!')
# 修改商品数量
def modify_quantity():
index = input('请输入要修改数量的商品编码:')
for product in products:
if product.index == index:
new_quantity = int(input('请输入新的商品数量:'))
product.number = new_quantity
print('商品数量修改成功!')
return
print('未找到该商品!')
# 主菜单
def main_menu():
while True:
print('1. 添加商品')
print('2. 查看商品列表')
print('3. 删除商品')
print('4. 修改商品数量')
print('5. 退出')
choice = input('请输入您的选择:')
if choice == '1':
add_product()
elif choice == '2':
view_products()
elif choice == '3':
delete_product()
elif choice == '4':
modify_quantity()
elif choice == '5':
break
else:
print('无效的选择,请重新输入!')
# 运行主菜单
main_menu()
```
图书库存管理系统python
以下是一个简单的图书库存管理系统的Python实现,包括添加、删除、查询和修改图书信息的功能:
```python
class Book:
def __init__(self, title, author, genre, year, copies):
self.title = title
self.author = author
self.genre = genre
self.year = year
self.copies = copies
class Library:
def __init__(self):
self.books = []
def add_book(self, book):
self.books.append(book)
def remove_book(self, book):
self.books.remove(book)
def search_book(self, title):
for book in self.books:
if book.title == title:
return book
return None
def modify_book(self, book, title=None, author=None, genre=None, year=None, copies=None):
if title:
book.title = title
if author:
book.author = author
if genre:
book.genre = genre
if year:
book.year = year
if copies:
book.copies = copies
# 示例代码
library = Library()
book1 = Book("The Great Gatsby", "F. Scott Fitzgerald", "Fiction", 1925, 3)
book2 = Book("To Kill a Mockingbird", "Harper Lee", "Fiction", 1960, 2)
library.add_book(book1)
library.add_book(book2)
print("Books in library:")
for book in library.books:
print(book.title)
print("Searching for 'The Great Gatsby'...")
book = library.search_book("The Great Gatsby")
if book:
print("Book found! Title:", book.title, "Author:", book.author, "Genre:", book.genre, "Year:", book.year, "Copies:", book.copies)
else:
print("Book not found.")
print("Modifying 'To Kill a Mockingbird'...")
book = library.search_book("To Kill a Mockingbird")
if book:
library.modify_book(book, copies=3)
print("Book modified! Title:", book.title, "Author:", book.author, "Genre:", book.genre, "Year:", book.year, "Copies:", book.copies)
else:
print("Book not found.")
print("Removing 'The Great Gatsby'...")
book = library.search_book("The Great Gatsby")
if book:
library.remove_book(book)
print("Book removed!")
else:
print("Book not found.")
```