什么是
python相当于:
if (strpos($elem,"text") !== false) { // do_something; }@H_403_3@
@H_403_3@
未找到时返回-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/
@H_403_3@