02_python闯关练习_01Password

Posted zhangyide

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了02_python闯关练习_01Password相关的知识,希望对你有一定的参考价值。

 判断密码是否:

  1. 长度大于10;

  2. 包含数字;

  3. 包含大写字母;

  4. 包含小写字母。

 1 # Author:Zhang Yide
 2 # coding:utf-8
 3 
 4 def password(data):
 5     ‘‘‘Check if password inputed is strong enough
 6 
 7     Its length is greater than or equal to 10 symbols;
 8     It has at least one digit;
 9     It has at least one uppercase letter and lowercase letter‘‘‘
10 
11     data = str(data)
12     HasDigit = any(i.isdigit() for i in data)
13     HasUpper = any(i.isupper() for i in data)
14     HasLower = any(i.islower() for i in data)
15     if HasDigit and HasUpper and HasLower and len(data) >= 10:
16         return True
17     else:
18         return False
19 
20 while True:
21     data = input("please input password:\n")
22     print(password(data))

 

以上是关于02_python闯关练习_01Password的主要内容,如果未能解决你的问题,请参考以下文章

week01_python基础语法__02

Python_数据类型练习题

python全栈闯关--15-内置函数

python练习_module02-1-ATM+购物车

Note on python__2021-07-02Python练习使用条件判断

python练习_module02-1-员工信息表