ถ้าส่วนข้อความอยู่ว่าไม่ได้อยู่ในข้อความเป็นภาษาไพธอน
fullstring = "StackAbuse"
substring = "tack"
if fullstring.find(substring) != -1:
print "Found!"
else:
print "Not found!"
ยังไงฉันตรวจสอบว่าเป็นบรรจุข้อความมีเหยื่อที่เป็นคำพูดน่ะเหรอ?
$a = 'Hello world?';
if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
echo 'true';
}
ค้นหาข้อความในข้อความเป็นภาษาไพธอน
>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False