无序字符串生成,字符串生成,Interactive


Interactive Window.py

import randomdef generateStr(N = 4,up = 1 ,lo = 1,nm = 1,sp = 1):    #init data    rstr,genStr,ist,sec,thi,fou,sR,sr,si,ss = 10*['']    uSum = up + lo + nm + sp    # exception handle    if uSum < 1 or uSum > N  :        print('Error Combine Input : ')        return 0    # exception handle    if up == 1 :        sR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'        ist = random.choice(list(sR))    if lo == 1 :        sr = 'abcdefghijklmnopqrstuvwxyz'        sec = random.choice(list(sr))    if nm == 1 :        si = '0123456789'        thi = random.choice(list(si))    if sp == 1 :        ss = '_.@#%^&*`\/'        fou = random.choice(list(ss))    astr = sR + sr + si + ss    for i in range(0,N-uSum):        rstr = rstr + random.choice(list(astr))    restr = rstr + ist + sec + thi + fou    #random the string    restr = list(restr)    random.shuffle(restr)    #list convert to string    for i in restr:         genStr += i    return genStrprint(generateStr(100,1,1,1,0))

评论关闭