“Obejmuje Python” Kod odpowiedzi

String Python zawiera podłoże

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

Obejmuje Python

if "blah" in somestring: 
    continue
Frodo Swagg1ns

Python zawiera ciąg

from re import search

fullstring = "StackAbuse"
substring = "tack"

if search(substring, fullstring):
    print "Found!"
else:
    print "Not found!"
Lucas Juan

Odpowiedzi podobne do “Obejmuje Python”

Pytania podobne do “Obejmuje Python”

Więcej pokrewnych odpowiedzi na “Obejmuje Python” w Python

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

Przeglądaj inne języki kodu