Home >Backend Development >Python Tutorial >Python random password generation tutorial
This article mainly introduces the method of generating random passwords in Python in detail. It has certain reference value. Interested friends can refer to it.
The example of this article shares with you how to generate random passwords in Python. The specific code of the bit string is 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 Python random password generation tutorial. For more information, please follow other related articles on the PHP Chinese website!