码迷,mamicode.com
首页 > 其他好文 > 详细

求随机码

时间:2019-03-16 23:25:56      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:add   return   random   随机   python   pytho   turn   int   ret   

import random
def r_code():
    code = ‘‘
    for i in range(6):
        num = random.randint(0,9)
        alf = chr(random.randint(65,90))
        add = random.choice([num,alf])
        code = "".join([code,str(add)])
    return code
print(r_code())

 

求随机码

标签:add   return   random   随机   python   pytho   turn   int   ret   

原文地址:https://www.cnblogs.com/kaiyuan111/p/10544789.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!