How to match a substring in a string, ignoring case

后端 未结 8 1784
既然无缘
既然无缘 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:26

    Try:

    if haystackstr.lower().find(needlestr.lower()) != -1:
      # True
    

提交回复
热议问题