How do I check for an EXACT word in a string in python

后端 未结 7 2094
再見小時候
再見小時候 2020-12-01 18:27

Basically I need to find a way to figure out a way to find the EXACT word in a string. All the information i have read online has only given me how to search for letters in

7条回答
  •  余生分开走
    2020-12-01 18:56

    I suspect that you are looking for the startswith() function. This checks to see if the characters in a string match at the start of another string

    "abcde".startswith("abc") -> true
    
    "abcde".startswith("bcd") -> false
    

    There is also the endswith() function, for checking at the other end.

提交回复
热议问题