Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ';如果';循环';带和不带';输入条件为真时打印消息_Python_Email_If Statement_Logic - Fatal编程技术网

Python ';如果';循环';带和不带';输入条件为真时打印消息

Python ';如果';循环';带和不带';输入条件为真时打印消息,python,email,if-statement,logic,Python,Email,If Statement,Logic,我正在尝试编写一个小代码,检查用户/键输入是否正确,代码是下一个: if emailstatus == True and email in UserKeys == True and UserKeys [email] == key : print ('Checked, you can log in ') else: print ('wrong email or password, you can not log in') ''' 当我输入正确的电子邮件和密码时,我仍然无

我正在尝试编写一个小代码,检查用户/键输入是否正确,代码是下一个:

if emailstatus == True and email in UserKeys == True and UserKeys [email] == key :

  print ('Checked,  you can log in ')    

else:

  print ('wrong email or password, you can not log in')
'''

当我输入正确的电子邮件和密码时,我仍然无法登录(这会生成三个真值)

我修复了将“()”添加到中的if条件(用户密钥中的电子邮件==True的问题

但我仍然不明白这个错误背后的逻辑

这是完整的程序代码吗


您的问题在于检查凭据时的if条件

你写了:

if emailstatus==True and email in UserKeys==True and UserKeys[email]==key:
在这里,您可以做两件事:

1) 删除
==True

更改后(1):
如果emailstatus==True,并在UserKeys和UserKeys中发送电子邮件[email]==key:

2) 或者将电子邮件放在括号中的UserKeys中,如下所示:
(UserKeys中的电子邮件)==True

更改后(2):
如果emailstatus==True和(email in UserKeys)==True和UserKeys[email]==key:


实际上,如果用户密钥中的
电子邮件
返回
True
如果该电子邮件存在,那么您不必明确检查它

在问题中添加一个文本。谢谢!这就是问题所在。不幸的是,我是新来的,还不能投票给你:没关系。很高兴这有帮助!