“Python Periksa apakah string berisi simbol” Kode Jawaban

Jika substring tidak dalam string python

fullstring = "StackAbuse"
substring = "tack"

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

Jika substring tidak dalam string python

>>> 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 jika string berisi arang

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 Periksa apakah string berisi substring

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 Periksa apakah string berisi simbol

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

Jawaban yang mirip dengan “Python Periksa apakah string berisi simbol”

Pertanyaan yang mirip dengan “Python Periksa apakah string berisi simbol”

Lebih banyak jawaban terkait untuk “Python Periksa apakah string berisi simbol” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya