假设我的字典字典叫做记录是这样的,其中第一、第二等是键
records = {
first: {
"email": email,
"password": password,
"pwd_secret" : None
}
second: {
"email": email,
"password": password,
"pwd_secret" : code
}
}
然后我检查代码是否等于pwd_secret任何字典中“”的值。该功能的代码可以完美运行,但是我的 else 语句不起作用(如果代码不是pwd_secret任何字典中“”的值,那么我想引发错误。但是目前即使代码存在,它也只会引发错误。) 有什么建议么?
for k, v in records.items():
pwd_secret = v.get('pwd_secret')
if pwd_secret == code:
hashed_password = hash_password(new_password)
v['password'] = hashed_password
#else:
#raise ValueError("code is invalid")
四季花海
皈依舞
哔哔one
相关分类