php – 什么是python相当于strpos($elem,“text”)!== false)
发布时间:2020-12-13 17:29:38 所属栏目:PHP教程 来源:网络整理
导读:什么是 python相当于: if (strpos($elem,"text") !== false) { // do_something; } 未找到时返回-1: pos = haystack.find(needle)pos = haystack.find(needle,offset) 当找不到时会引发ValueError: pos = haystack.index(needle)pos = haystack.index(nee
什么是
python相当于:
if (strpos($elem,"text") !== false) { // do_something; }
未找到时返回-1:
pos = haystack.find(needle) pos = haystack.find(needle,offset) 当找不到时会引发ValueError: pos = haystack.index(needle) pos = haystack.index(needle,offset) 要简单地测试一个子串是否在字符串中,请使用: needle in haystack 这相当于以下PHP: strpos(haystack,needle) !== FALSE 从http://www.php2python.com/wiki/function.strpos/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |