Python字符串比較忽略大小寫的方法

A.正則表達式,使用IGNORECASE標誌正則表達式 >>> import re >>> m = re.search('multi', 'A mUltiCased string', re.IGNORECASE) >>> bool(m) True B.在比較前把2個字符串轉換成一樣大寫,用upper()方法,或小寫,lower() >>> s = 'A mUltiCased string'.low
相關文章
相關標籤/搜索