📌  相关文章
📜  无论大小写,python 都查找匹配的字符串 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:59.421000             🧑  作者: Mango

代码示例1
# credit to the Stack Overflow users in the source lin
# with regex
import re
if re.search('mandy', 'Mandy Pande', re.IGNORECASE):
   # do your stuff here
   # Note:
   # results = re.search('mandy', 'Mandy Pande', re.IGNORECASE)
   # results.group(0) is the string that matched ('Mandy')

# without regex
string1 = "hi"
string2 = "HI"
if string1.lower() == string2.lower():
    print("Equals!")
else:
    print("Different!")