python产生随机字符串

来源:互联网 发布:aisino金税盘开票软件 编辑:程序博客网 时间:2024/05/01 14:41

python产生随机字符串


def GenerateRandomString(len, basechars = []):     if (basechars == []):         x = range(ord('a'), ord('z') + 1)         x.extend(range(ord('A'), ord('Z') + 1))         x.extend(range(ord('0'), ord('9') + 1))         basechars = [chr(i) for i in x]         ret = ''         for i in range(len):            ret += random.choice(basechars)         return ret

0 0