创客百科

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

用户工具

站点工具


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

Python判断字符串是否包含另一字符串的方法

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
本页面的其他翻译:
note/spoony/python判断字符串是否包含另一字符串的方法.txt · 最后更改: 2016/12/27 23:46 由 Spoony