def strong_password():
password = input('Please input your password: ')
length = re.compile(r'.{8,}')
uppercase = re.compile(r'[A-Z]')
lowercase = re.compile(r'[a-z]')
digit = re.compile(r'[0-9]')
if length.search(password) == None:
return 'Not strong!'
elif uppercase.search(password) == None:
return 'Not strong!'
elif lowercase.search(password) == None:
return 'Not strong!'
elif digit.search(password) == None:
return 'Not strong!'
return 'it is a strong password.'
写入为一个函数,这样就可以更加方便来调用了。