python换行生成100个随机收货地址
时间: 2023-11-11 10:04:30 浏览: 145
python生成随机mac地址的方法
好的,你可以使用以下代码生成100个随机收货地址:
```python
import random
streets = ["Main Street", "Broadway", "Park Avenue", "Maple Street", "Pine Street"]
cities = ["New York", "Los Angeles", "Chicago", "Houston", "Phoenix"]
states = ["NY", "CA", "IL", "TX", "AZ"]
for i in range(100):
street_num = random.randint(1, 1000)
street = random.choice(streets)
city = random.choice(cities)
state = random.choice(states)
zip_code = random.randint(10000, 99999)
print(f"{street_num} {street}\n{city}, {state} {zip_code}\n")
```
这段代码会输出100个随机生成的收货地址,每个地址包括街道、城市、州和邮政编码。
阅读全文