码迷,mamicode.com
首页 > 编程语言 > 详细

02_python闯关练习_01Password

时间:2018-01-06 17:14:59      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:dig   div   length   author   长度   put   cas   uppercase   style   

 判断密码是否:

  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

标签:dig   div   length   author   长度   put   cas   uppercase   style   

原文地址:https://www.cnblogs.com/zhangyide/p/8214635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!