簡體   English   中英

當我嘗試比較python中的兩個字符串時,我在python中得到錯誤的結果

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM