|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import easygui as g
import string as s
import random
a = s.ascii_letters+s.digits
def getKey(): # 产生随机字符串
key=random.sample(a,10)
keys="".join(key)
return keys
msg = '请输入账户和密码:'
title = '登录账号'
filed_name = ['用户名:','密码:']
while 1:
password = ''
temp = g.multpasswordbox(msg ,title,filed_name)
if temp == None:
break
elif temp == '' or temp[0] != '' and temp[1] == '':
g.msgbox('密码错误,请重新输入!')
elif temp[0] == '52154615':
password = '12345678'
if temp[1] == password:
g.msgbox('密码正确!')
break
else:
g.msgbox('密码错误,请重新输入!')
print('用户名:%s' % temp[0])
print(('密码提示:%s···' % password[:4]))
elif temp[0] is not ['77444445','961182830','52154615']:
password = getKey() # 调用获取随机密码的函数
count = 3
while count > 0:
temp = g.multpasswordbox(msg, title, filed_name)
if temp[1] == password:
g.msgbox('密码正确!')
break
else:
g.msgbox('密码错误,请重新输入!')
print('用户名:%s' % temp[0])
print(('密码提示:%s···' % password[:4]))
count -= 1
萌新求问时间:
TypeError: 'NoneType' object is not subscriptable
每次输入不是['77444445','961182830','52154615']这三个账号的时候,密码如果输错了,返回登录界面然后cancel 就会报错
第40行(红色字体那行)没有判断第39行返回temp为None的情况(点取消返回None)。
|
|