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

后端 未结 7 2061
再見小時候
再見小時候 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 19:01

    You can make a few changes.

    elif 'This is correct' in text[:len('This is correct')]:
    

    or

    elif ' This is correct ' in ' '+text+' ':
    

    Both work. The latter is more flexible.

提交回复
热议问题