首页 > 代码库 > 获取指定长度的随机字符串

获取指定长度的随机字符串

s = ‘‘
chars = abcdefghijklmnopqrstuvwxyz0123456789
length = len(chars) - 1
random = Random()
for i in range(31):
    s += chars[random.randint(0, length)]

x = int(time.time() * 1000)
s = str(x)+s

 

获取指定长度的随机字符串