[英]I am getting wrong result in python when I trying to compare the two strings in python
Why I am getting wrong result when I compare the two strings . 比较两个字符串时为什么会得到错误的结果。
if password==en_pass:
log.info("##### client credentials are OK ####")
else:
print "credentials are wrong "
i am getting the result which is in else block 我得到的结果在else块中
Here is the my log message: 这是我的日志消息:
got the password :bmF2ZWVu , encoded password :bmF2ZWVu
where encoded password is from base64
, that is i got that by using encodestring method in base 64
module. 编码的密码来自
base64
,即我是通过在base 64
模块中使用encodestring方法得到的。
it seems that password is not 'bmF2ZWVu'
, but contains trailing spaces, like 'bmF2ZWVu '
. 似乎密码不是
'bmF2ZWVu'
,而是包含尾随空格,例如'bmF2ZWVu '
。 Try if password.strip()==en_pass.strip()
尝试
if password.strip()==en_pass.strip()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.