Python produces 1 12-digit random passwords using the random shuffle Shuffle method

Source: Internet
Author: User
Tags random shuffle shuffle shuffle shuffle

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.