基于Python的仓库管理系统
时间: 2023-11-05 13:56:37 浏览: 80
基于Python的仓库管理系统可以使用Python的各种库和框架进行开发。下面是一个简单的示例:
```python
class Warehouse:
def __init__(self):
self.inventory = {}
def add_item(self, item, quantity):
if item in self.inventory:
self.inventory[item] += quantity
else:
self.inventory[item] = quantity
def remove_item(self, item, quantity):
if item in self.inventory:
if quantity >= self.inventory[item]:
del self.inventory[item]
else:
self.inventory[item] -= quantity
def display_inventory(self):
for item, quantity in self.inventory.items():
print(f"{item}: {quantity}")
# Example usage:
warehouse = Warehouse()
warehouse.add_item("apple", 10)
warehouse.add_item("banana", 5)
warehouse.display_inventory()
# Output:
# apple: 10
# banana: 5
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_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)