Python3----output all uppercase and lowercase letters and numbers

Source: Internet
Author: User

1. Output all large (small) letters with one line, and numbers

1 Print([Chr (i) forIinchRange (65, 91)])#All uppercase Letters2 Print([Chr (i) forIinchRange (97, 123)])#All lowercase letters3 Print([Chr (i) forIinchRange (48, 58)])#All numbers4 5 ####################6['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']7['a','b','C','D','e','F','g','h','I','J','k','L','m','N','o','P','Q','R','s','T','u','v','W','x','y','Z']8['0','1','2','3','4','5','6','7','8','9']

1 ImportString#Import string This module2 Print(string.digits)#output A string containing a numeric 0~93 Print(string.ascii_letters)#A string containing all letters (uppercase or lowercase)4 Print(string.ascii_lowercase)#a string containing all lowercase letters5 Print(string.ascii_uppercase)#A string containing all uppercase letters6 7 8 ##############90123456789Ten abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz One abcdefghijklmnopqrstuvwxyz AAbcdefghijklmnopqrstuvwxyz

2. Generate Random Verification code

1 Import Random 2 def Get_code (): 3     Source = List ('0123456789')4for in      Range (123):5        source.append (Chr (i))6     print( '. Join (Random.sample (source, 4)))

1 def V_code (): 2     "' 3      for  in range (5):4         add = Random.choice ([Random.randrange], Chr (Random.randrange ( (123)])5         code + = str (add)6     print(code)

Python3----output all uppercase and lowercase letters and numbers

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.