Tag:shuffle python import password
1 # !/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 import random 4 &NBSP;&NBSP;&NBSP;5&NBSP;SCHR&NBSP;=&NBSP;[CHR (s) for s in range (65,91)] &NBSP;&NBSP;&NBSP;6&NBSP;BCHR&NBSP;=&NBSP;[CHR (b) for b in range (97,123)] &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;7&NBSP;NUM&NBSP;=&NBSP;[STR (n) for n in range ( 0,10)] 8 signs = ['! ', ' @ ', ' # ', ' $ ', '% ', ' ^ ', ' & ', ' * ', ' (', ') ', ' + ', '-', ' _ ', ' = ', ' < ', ' > ', ' ', ' ' | ', ' [', '] ', '? ', '/'] 9 codes = schr + bchr + num + signs 10 11 def Shuffle (codes): 12 for i in range (5): 13 random.shuffle ( Codes) 14 return codes 15 16 def get_code (codes): 17 codes = shuffle (Codes) 18 rand_ Start = random.randint (0,len (codes) -12) 19 rand_end = rand_start + 12 20 return '. Join (Codes[rand_start:rand_end]) 21 22 print Get_code (Codes)
This article is from the "Bobo Road" blog, reprint please contact the author!
Python produces 1 12-digit random passwords using the random shuffle Shuffle method