创客百科

姿势共享,有节操无门槛参与的创客百科,创客动力之源 \ (^_^) /

用户工具

站点工具


note:spoony:python判断字符串是否包含另一字符串的方法

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

note:spoony:python判断字符串是否包含另一字符串的方法 [2016/12/27 23:46] (当前版本)
Spoony 创建
行 1: 行 1:
 +====== Python判断字符串是否包含另一字符串的方法 ======
 +<​code>​
 +site = '​123'​
 +if "​12"​ in site:
 +   ​print('​site contains 12')
  
 +
 +s = "This be a string"​
 +if s.find("​is"​) == -1:
 +  print "No '​is'​ here!"
 +else:
 +  print "Found '​is'​ in the string."​
 +
 +contains = '​abcde'​.find('​bcd'​) >= 0
 +
 +
 +contains = '​abcde'​.count('​bcd'​) > 0
 +</​code>​
note/spoony/python判断字符串是否包含另一字符串的方法.txt · 最后更改: 2016/12/27 23:46 由 Spoony