目前已经生成了30个数的列表,帮写python代码表示这30个数分别对应一个顾客
时间: 2024-02-05 08:03:14 浏览: 20
当然,请看下面的代码示例:
```python
customers = []
# 生成30个随机数
numbers = [12, 34, 56, 78, 90, 23, 45, 67, 89, 10, 32, 54, 76, 98, 21, 43, 65, 87, 9, 31, 53, 75, 97, 20, 42, 64, 86, 8, 30]
# 为每个数创建一个顾客对象
for num in numbers:
customer = {'number': num}
customers.append(customer)
# 打印顾客列表
for customer in customers:
print(customer)
```
这段代码将生成一个包含30个数的列表 `numbers`,然后为每个数创建一个包含该数的顾客对象,并将对象添加到 `customers` 列表中。每个顾客对象都有一个 `number` 属性来存储对应的数。最后,通过遍历 `customers` 列表,可以打印出每个顾客对象的信息。请注意,这里给出的数字只是示例,你可以根据实际需求修改。