Home  >  Article  >  Backend Development  >  Python implementation confirms whether a string contains an instance of the specified string

Python implementation confirms whether a string contains an instance of the specified string

不言
不言Original
2018-05-02 14:02:572101browse

This article mainly introduces the example of Python implementation to confirm whether a string contains a specified string. It has a certain reference value. Now I share it with you. Friends in need can refer to it

Sometimes we We need to search in a certain string or a certain statement to confirm whether it contains the string information we need.

For example,

The segment variable is: A= ”My name is Clay, and you can get my name”

A = "My name is Clay, and you can get my name“ 
myName = "Clay" 
if myName in A: 
 //do what you want to do

And we need to find whether A contains Clay field.

Related recommendations:

Python examples of adding variables to strings

Python finds characters in strings Location instance

The above is the detailed content of Python implementation confirms whether a string contains an instance of the specified string. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn