首页 > 技术文章 > 获取指定长度的随机字符串

caicaihong 2017-04-10 19:52 原文

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

 

推荐阅读