Home > Backend Development > Python Tutorial > How to generate random passwords in Python

How to generate random passwords in Python

黄舟
Release: 2017-06-18 11:21:26
Original
1719 people have browsed it

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template