print'Your password must contain the following.. \n\n - at least 1 uppercase letter\n - at least 1 lowercase letter \n - at least 1 number \n - at least 7 characters' # Tells the user what the password requires
password = 0 #Sets the password at 0 , gives an entry point into the while loop
while password <7: #This while loop, while the password count is less than 7 execute the following
s=raw_input('\nPlease choose a password: ') #Giving the password a variable
errors = [] #?????????????????????
if not any(x.isupper() for x in s): #This is testing if there is NOT any uppercase characters in the string
errors.append('\nERROR Your password needs at least 1 capital letter')
if not any (x.islower() for x in s):
errors.append('\nERROR Your password needs at least 1 lower case letter')
if not any (x.isdigit() for x in s):
errors.append('\nERROR Your password needs at least 1 number')
if len(s)< 7:
print '\nERROR Your password needs to be at least 7 characters'
if errors:
print '\n'.join(errors)
if (any(x.isupper() for x in s) and any(x.islower() for x in s) and any(x.isdigit() for x in s) and len(s) >= 7):
print '\n\nGreat, your all set up and ready to go. \n\nYour login:',login, '\nYour password:',s
password = password +7
答案 0 :(得分:2)
在python中[]
表示创建一个空列表。
您也可以使用error = list()
它也是一样的。
然后,您将该列表分配给名为error
的变量名称:
error = []
稍后,您使用error.append()
,这意味着您将元素放在引用名称error
的列表的末尾。