[ Python - 5 ] 通过random模块生成随机字符串

import random
checkcode = ''
for i in range(4):
    if i == random.randint(0,3):
        current = chr(random.randrange(65,90))
        checkcode += str(current)
    else:
        checkcode += str(i)

print(checkcode)
View Code

 

posted @ 2017-06-25 07:16  hukey  阅读(745)  评论(0编辑  收藏  举报