문자열에 특정 문자 파이썬이 포함되어 있는지 확인하십시오

코드 예제

2
0

N

myString = "<text contains this>"
myOtherString = "AnotherString"

# Casting to string is not needed but it's good practice
# to check for errors 

if str(myString) in str(myOtherString): 
    # Do Something
else:
	# myOtherString didn't contain myString
    
1
0

N

yourString = "string"

if "s" in yourString:
  print("There is an S in your string")
  
if "s" not in yourString:
  print("There is no S in your string")
1
0

N

>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False
1
0

N

myString = "God is good"

if "o" in myString[0:4]
	print("Working! There is an 'O' in between the G and D of God.")
0
0

N

if '$' in myString:

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................