[Python] python判断一个字符串是否包含另外一个字符串 →→→→→进入此内容的聊天室

来自 , 2019-03-02, 写在 Python, 查看 163 次.
URL http://www.code666.cn/view/5ef99d16
  1. #!/usr/bin/env python
  2. #
  3. # [SNIPPET_NAME: String contains string test]
  4. # [SNIPPET_CATEGORIES: Python Core]
  5. # [SNIPPET_DESCRIPTION: Test if a string contains another string]
  6. # [SNIPPET_AUTHOR: Jono Bacon <jono@ubuntu.com>]
  7. # [SNIPPET_LICENSE: GPL]
  8.  
  9.  
  10. my_string = "abcdef"
  11.  
  12. if "abc" in my_string:
  13.     has_abc = True
  14.  
  15. if has_abc == True:
  16.     print "String contains string."
  17. #//python/2367

回复 "python判断一个字符串是否包含另外一个字符串"

这儿你可以回复上面这条便签

captcha