This article mainly introduces in detail the method of generating random passwords in Python, which has certain reference value. Interested friends can refer to it
The examples in this article are for everyone Shared the specific code for python to generate a random 10-digit string for your reference. The specific content is as follows
##
#coding:utf-8 #利用python生成一个随机10位的字符串 import string import random import re list = list(string.lowercase + string.uppercase) + [ str(i) for i in range(10)] FH = ('!','@','#','$','%','&','_') for f in FH: list.append(f) num = random.sample(list,10) '''随机取出10个数''' str='' value = str.join(num) #将取出的十个随机数进行重新合并 if not value[0].isdigit(): print value
The above is the detailed content of How to generate random passwords in Python. For more information, please follow other related articles on the PHP Chinese website!