“Python Sprawdź, czy ciąg zawiera symbole” 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

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

Python, jeśli ciąg zawiera char

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
    
Av3

Python Sprawdź, czy ciąg zawiera podłoże

string = "My favourite programming language is Python"
substring = "Python"

if substring in string:
    print("Python is my favorite language")
elif substring not in string:
    print("Python is not my favourite language")
micheal d higgins left nut

Python Sprawdź, czy ciąg zawiera symbole

any(not c.isalnum() for c in string)
MitchAloha

Odpowiedzi podobne do “Python Sprawdź, czy ciąg zawiera symbole”

Pytania podobne do “Python Sprawdź, czy ciąg zawiera symbole”

Więcej pokrewnych odpowiedzi na “Python Sprawdź, czy ciąg zawiera symbole” w Python

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

Przeglądaj inne języki kodu