python判断一个字符串中是否包含某个子字符串

char = ‘abcdefghijklmnopqrstuvwxyz’

1)方法1
if “abc” in char:
     print(“找到啦”)

2)方法2
if char.find(“abc”) >=0:
    print(“找到啦”)

发布了191 篇原创文章 · 获赞 104 · 访问量 34万+

猜你喜欢

转载自blog.csdn.net/u013925378/article/details/102820042