import random
def generate_license_plate():
# 生成车牌号码的前缀
prefix = random.choice(
['京', '津', '冀', '晋', '蒙', '辽', '吉', '黑', '沪', '苏', '浙', '皖', '闽', '赣', '鲁', '豫', '鄂', '湘', '粤', '桂', '琼', '渝',
'川', '贵', '云', '藏', '陕', '甘', '青', '宁', '新'])
# 生成车牌号码的数字部分
numbers = random.randint(10000, 99999)
# 生成车牌号码的字母部分
letters = random.choice(
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z'])
# 组合生成的车牌号码
license_plate = f"{prefix}{letters}{numbers}"
return license_plate
# 调用函数生成车牌号码
license_plate = generate_license_plate()
print(license_plate)
python生成车牌号
最新推荐文章于 2024-09-13 08:53:03 发布