如何進行不區(qū)分大小寫的字符串比較?如何在Python中進行不區(qū)分大小寫的字符串比較?我想用一種非常簡單和Pythonic的方式封裝規(guī)則字符串與存儲庫字符串的比較。我還希望能夠在使用常規(guī)python字符串的字符串散列中查找值。
3 回答

一只斗牛犬
TA貢獻1784條經驗 獲得超2個贊
string1 = 'Hello'string2 = 'hello'if string1.lower() == string2.lower(): print("The strings are the same (case insensitive)")else: print("The strings are NOT the same (case insensitive)")
添加回答
舉報
0/150
提交
取消