我想创建一个用户在控制台中输入密码的小程序。然后,程序根据用户输入的内容检查密码是弱,中或强。Python - 检查数字,大写,小写字母和特殊字符的输入
我需要检查输入了多少个大写,小写和数字,然后告诉用户密码的强度。
我已经完成了大部分程序,但由于我没有真正使用过Python,所以我不太熟悉任何先进的东西,请记住,年轻人也必须理解这些代码,这些代码不会很好在编码自己。
到目前为止,我有:
#Welcome the user to the application.
print("Hello, please enter a password to check how secure it is");
#Set a variable called MinPass and set a value of 6.
MinPass = 6;
#Set a variable called MaxPass and set a value of 12.
MaxPass = 12;
#Set variable EnteredPass and wait for user input
EnteredPass = input("Password: ");
while len(EnteredPass) < MinPass:
print("Your password is too short, please enter a longer password and try again")
EnteredPass = input("Password: ");
while len(EnteredPass) > MaxPass:
print("Your password is too long, please shorten it and try again!");
EnteredPass = input("Password: ");
请注意,这仅仅是为了教育目的。我不打算制作一个旨在窃取随机密码的程序。这是我校学习课程的一部分!
你还没有做出很多尝试,你呢?你有没有看过['str'类型方法](http://docs.python.org/2/library/stdtypes.html#string-methods)? –
@MartijnPieters他们已经设置了一些变量:)我只是想知道什么是“womabt”是:) –
虽然,我已经回答了您的问题,并且有更多的人可以回答这些问题,我会建议您在提问关于SO的问题之前,先看一下python的文档(或者你正在学习的语言)。即使是最好的程序员,也要继续参考语言的文档。另外,python提供的文档非常好。 –