1. 程式人生 > >生成包含大寫字母,小寫字母,數字的隨機字串

生成包含大寫字母,小寫字母,數字的隨機字串

https://blog.csdn.net/caoxinjian423/article/details/82873830

import random
 
randomStr= ""
 
for i in range(6):
    temp = random.randrange(0,3)
    if temp == 0:
        ch = chr(random.randrange(ord('A'),ord('Z') + 1))
        randomStr += ch
    elif temp == 1:
        ch = chr(random.randrange(ord('a'),ord('z') + 1))
        randomStr += ch
    else:
        ch = str((random.randrange(0,10)))
        randomStr += ch
 
print(randomStr)
---------------------  
作者:書院二層樓  
來源:CSDN  
原文:https://blog.csdn.net/caoxinjian423/article/details/82873830  
版權宣告:本文為博主原創文章,轉載請附上博文連結!