1. 程式人生 > >python3 密碼生成器

python3 密碼生成器

用random模組實現按照要求生成一定個數和一定位數的密碼:

+ View Code ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #Author by Andy #_*_ coding:utf-8 _*_ import random checkcode = '' code = '''[email protected]
#%&()*"{}'''
code_len = int ( input ( '請輸入密碼長度:' )) code_count = int ( input ( '請輸入密碼個數:' )) count
= 0 while count < code_count:      checkcode = ''      for i in range (code_len):          j = random.randint( 0 , len (code) - 1 )          checkcode + = code[j]      print (checkcode)      count + = 1

  

用random模組實現按照要求生成一定個數和一定位數的密碼:

+ View Code ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #Author by Andy #_*_ coding:utf-8 _*_ import random checkcode = '' code = '''[email protected]#%&()*"{}''' code_len = int ( input ( '請輸入密碼長度:' )) code_count = int ( input ( '請輸入密碼個數:' )) count = 0 while count < code_count:      checkcode = ''      for i in range (code_len):          j = random.randint( 0 , len (code) - 1 )          checkcode + = code[j]      print (checkcode)      count + = 1