如果检查一串包含有特定字蟒蛇

代码示例

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
..................................................................................................................