“Jeśli nie podłoże w Pythonie String” Kod odpowiedzi

Jeśli nie podłoże w Pythonie String

fullstring = "StackAbuse"
substring = "tack"

if fullstring.find(substring) != -1:
    print "Found!"
else:
    print "Not found!"
riffrazor

Ciąg Python zawiera

>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False
Misty Macaw

Jeśli nie podłoże w Pythonie String

>>> string = "Hello World"
>>> # Check Sub-String in String
>>> "World" in string
True
>>> # Check Sub-String not in String
>>> "World" not in string
False
peamdev

Jak sprawdzić podłoże w Pythonie

def find_string(string,sub_string):
	return string.find(sub_string)
#.find() also accounts for multiple occurence of the substring in the given string
san_bt

Python Sprawdź, czy wartość w ciągu

def is_value_in_string(value: str, the_string: str):
    return value in the_string.lower()
DeuxAlpha

String Python nie zawiera

str = '£35,000 per year'
# check for '£' character in the string
'£' not in str
# >> False
'£' in str
# >> True 
Worrisome Wallaby

Odpowiedzi podobne do “Jeśli nie podłoże w Pythonie String”

Pytania podobne do “Jeśli nie podłoże w Pythonie String”

Więcej pokrewnych odpowiedzi na “Jeśli nie podłoże w Pythonie String” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu