论Python的random库如何随机生成token值

from random import Random
 
# 随机生成token
def get_token():
    length_r = 32
    token = ''
    chars = '01'
    length = len(chars) - 1
    random = Random()
    for i in range(length_r):
        token += chars[random.randint(0, length)]
    return token

感觉还行的话,帮忙点个赞吧



猜你喜欢

转载自www.cnblogs.com/ldpgg/p/12651580.html