문자열 파이썬에 하위 문자열이없는 경우
fullstring = "StackAbuse"
substring = "tack"
if fullstring.find(substring) != -1:
print "Found!"
else:
print "Not found!"
파이썬 str 에는 단어가 포함되어 있습니다
fullstring = "StackAbuse"
substring = "tack"
if substring in fullstring:
print "Found!"
else:
print "Not found!"
파이썬에서 문자열에 단어가 있는지 확인하는 방법
>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False
파이썬은 문자열에 문자열이 있는지 확인합니다
if "blah" not in somestring:
continue
파이썬에서 부분 문자열을 확인하는 방법
def find_string(string,sub_string):
return string.find(sub_string)
#.find() also accounts for multiple occurence of the substring in the given string
문자열에 특정 단어가 포함되어 있는지 어떻게 확인합니까?
$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}