nav*_*nam 0 python string comparison
当我比较两个字符串时,为什么我得到错误的结果.
if password==en_pass:
log.info("##### client credentials are OK ####")
else:
print "credentials are wrong "
Run Code Online (Sandbox Code Playgroud)
我得到的结果是在else块中
这是我的日志消息:
got the password :bmF2ZWVu , encoded password :bmF2ZWVu
Run Code Online (Sandbox Code Playgroud)
编码密码来自哪里base64,就是我通过在base 64模块中使用encodestring方法得到的.
似乎密码不是'bmF2ZWVu',但包含尾随空格,如'bmF2ZWVu '.尝试if password.strip()==en_pass.strip()