PYTHON-模塊 sys os random shutil-練習

# 做業:# 添加工程根目錄至環境變量 要求能夠跨平臺# import sys,os# BATH_DIR=os.path.dirname(os.path.dirname(__file__))# sys.path.append(BATH_DIR)#  1.課堂上的隨機驗證碼練習# 長度5 包括0-9 A-Z a-zimport randomdef get_auth_code(lenght):    res=''    for i in range(lenght):        a=random.randint(0,9)        b=chr(random.randint(65,90))        c=chr(random.randint(97,122))        s=random.choice([a,b,c])        res+=str(s)    return resprint(get_auth_code(5))
相關文章
相關標籤/搜索