[英]I am getting wrong result in python when I trying to compare the two strings in python
比較兩個字符串時為什么會得到錯誤的結果。
if password==en_pass:
log.info("##### client credentials are OK ####")
else:
print "credentials are wrong "
我得到的結果在else塊中
這是我的日志消息:
got the password :bmF2ZWVu , encoded password :bmF2ZWVu
編碼的密碼來自base64
,即我是通過在base 64
模塊中使用encodestring方法得到的。
似乎密碼不是'bmF2ZWVu'
,而是包含尾隨空格,例如'bmF2ZWVu '
。 嘗試if password.strip()==en_pass.strip()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.