Python生成字母,数字,特殊符号组成的随机密码,python特殊符号,Python生成字母,数
Python生成字母,数字,特殊符号组成的随机密码,python特殊符号,Python生成字母,数
Python生成字母,数字,特殊符号组成的随机密码
from random import choice as randomChoiceglobal passDataglobal passwordpassData = ['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', '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', '!', '@', '#', '$', '%', '^', '&', '*', '-', '_', '=', '+', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', ' ']def newPass(): while True: try: passwdNum = int(raw_input("Enter max number of characters: ")) except TypeError: print "Please enter a digit." continue break gen(passwdNum)def gen(number): password = [] number = int(number) count = 0 print "\nGenerating password..." while count != number: password.append(randomChoice(passData)) count += 1 x = 0 p = '' while x != len(password): p = p + str(password[x]) x += 1 print "Password generated.", print "Here's your %s character password. Note that there may be spaces: %s" % (len(password), p)newPass()
这段小程序对于定期修改账户密码会很有用。
相关内容
- Tkinter的ToolTip控件,tkintertooltip,Tkinter的Tool
- python中的filter方法,pythonfilter方法,filter函数:fil
- python自动连接ssh的代码,pythonssh代码,python自动连接ss
- Python处理命令行参数示例代码,python示例代码,下面代码
- Python实现简单的web server,pythonwebserver,这是Python实现的
- Python计算程序运行时间,python计算程序运行,使用time模
- python计算圆周率pi,python圆周率pi,from sys imp
- Python通过深拷贝实现从实例继承,python实例,Take an ins
- python刷新浪微博粉丝,python新浪博粉丝,之前有个哥们老
- python flatten sequences,flattensequences,A simple met
评论关闭