How to match a substring in a string, ignoring case

后端 未结 8 1786
既然无缘
既然无缘 2020-12-08 12:58

I\'m looking for ignore case string comparison in Python.

I tried with:

if line.find(\'mandy\') >= 0:

but no success for ignore

8条回答
  •  庸人自扰
    2020-12-08 13:25

    You can use in operator in conjunction with lower method of strings.

    if "mandy" in line.lower():

提交回复
热议问题