一、Python
# @File : 生成随机密码.py
# @desc :
import string
import random
####侯选
all_words = list(string.ascii_lowercase +string.ascii_uppercase + string.digits + string.punctuation)
###随机打散
random.shuffle(all_words)
###得到密码
#print("".join(all_words))
#如: h3(W*e.'6ik1{JGYtuS5sjqA,Xnrv7|IloQ>";+TF8HC!~0&KN}cMVEOz_gR)=?/P@d#w:Uba-[\%p9xD2<4Bmf`]^$yZL
print("".join(all_words[:20]))
二、Shell
< /dev/urandom tr -dc _A-Z-a-z-0-9#+@^$% |head -c32;echo
标签:shell,string,python,random,密码,随机,words,ascii From: https://www.cnblogs.com/chinaops/p/16879878.html