之前做課設(shè)的時(shí)候舍友遇到了需要生成500w量級(jí)車牌號(hào)的問題,于是我便寫了一個(gè)隨機(jī)生成車牌號(hào)的程序,希望各位采納。
注:Python實(shí)現(xiàn)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import random def chepaihao( len = 6 ): char0 = '京津滬渝冀豫云遼黑湘皖魯新蘇浙贛鄂桂甘晉蒙陜吉閩贛粵青藏川寧瓊' char1 = 'ABCDEFGHJKLMNPQRSTUVWXYZ' #車牌號(hào)中沒有I和O,可自行百度 char2 = '1234567890' len0 = len (char0) - 1 len1 = len (char1) - 1 len2 = len (char2) - 1 while True : code = '' index0 = random.randint( 1 ,len0 ) index1 = random.randint( 1 , len1) code + = char0[index0] code + = char1[index1] for i in range ( 1 , 6 ): index2 = random.randint( 1 , len2) code + = char2[index2] print (code) if __name__ = = '__main__' : chepaihao( len ) |
部分運(yùn)行結(jié)果如下
總結(jié)
以上所述是小編給大家介紹的Python實(shí)現(xiàn)隨機(jī)生成任意數(shù)量車牌號(hào),希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)服務(wù)器之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
原文鏈接:https://blog.csdn.net/weixin_45939019/article/details/104054387