仓库管理系统python源码
时间: 2024-06-16 22:04:12 浏览: 18
仓库管理系统是一个用于管理仓库库存、进货、出货等操作的软件系统。下面是一个简单的仓库管理系统的Python源码示例:
```python
class Product:
def __init__(self, name, quantity):
self.name = name
self.quantity = quantity
class Warehouse:
def __init__(self):
self.products = []
def add_product(self, product):
self.products.append(product)
def remove_product(self, product):
self.products.remove(product)
def get_product_quantity(self, product_name):
for product in self.products:
if product.name == product_name:
return product.quantity
return 0
def update_product_quantity(self, product_name, quantity):
for product in self.products:
if product.name == product_name:
product.quantity = quantity
break
# 示例用法
warehouse = Warehouse()
# 添加产品
product1 = Product("A", 10)
product2 = Product("B", 5)
warehouse.add_product(product1)
warehouse.add_product(product2)
# 获取产品数量
print(warehouse.get_product_quantity("A")) # 输出:10
# 更新产品数量
warehouse.update_product_quantity("A", 15)
print(warehouse.get_product_quantity("A")) # 输出:15
# 移除产品
warehouse.remove_product(product1)
print(warehouse.get_product_quantity("A")) # 输出:0
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)