find vs in operation in string python

前端 未结 3 839
無奈伤痛
無奈伤痛 2020-12-15 19:32

I need to find pattern into string and found that we can use in or find also. Could anyone suggest me which one will be better/fast on string. I need not to find index of pa

3条回答
  •  佛祖请我去吃肉
    2020-12-15 20:02

    Using in will be faster as using in provides only pattern while if you use find it will give you pattern as well as its index so it will take some extra time in computing the index of the string as compared to in. However if you are not dealing with large data then it dosent matter what you use.

提交回复
热议问题