Python衣服信息管理系统
时间: 2024-01-05 12:02:16 浏览: 25
以下是一个Python衣服信息管理系统的例子:
```python
class Clothes:
def __init__(self, name, color, size, price):
self.name = name
self.color = color
self.size = size
self.price = price
class ClothesManagementSystem:
def __init__(self):
self.clothes_list = []
def add_clothes(self, clothes):
self.clothes_list.append(clothes)
def remove_clothes(self, clothes):
self.clothes_list.remove(clothes)
def search_clothes(self, name):
for clothes in self.clothes_list:
if clothes.name == name:
return clothes
return None
def display_all_clothes(self):
for clothes in self.clothes_list:
print("Name: {}, Color: {}, Size: {}, Price: {}".format(clothes.name, clothes.color, clothes.size, clothes.price))
# 示例
cms = ClothesManagementSystem()
cms.add_clothes(Clothes("T-shirt", "Red", "M", 29.99))
cms.add_clothes(Clothes("Jeans", "Blue", "L", 49.99))
cms.add_clothes(Clothes("Dress", "Black", "S", 79.99))
cms.display_all_clothes()
# 输出:
# Name: T-shirt, Color: Red, Size: M, Price: 29.99
# Name: Jeans, Color: Blue, Size: L, Price: 49.99
# Name: Dress, Color: Black, Size: S, Price: 79.99
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)