“Python zawiera ciąg” Kod odpowiedzi

String Python zawiera podłoże

fullstring = "StackAbuse"
substring = "tack"

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

Python Str zawiera słowo

fullstring = "StackAbuse"
substring = "tack"

if substring in fullstring:
    print "Found!"
else:
    print "Not found!"
Comfortable Cottonmouth

Ciąg Python zawiera

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

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 “Python zawiera ciąg”

Pytania podobne do “Python zawiera ciąg”

Więcej pokrewnych odpowiedzi na “Python zawiera ciąg” w Python

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

Przeglądaj inne języki kodu