count() 函数
str = "this is string example....wow!!!"
sub = "i"
print("str.count(sub, 4, 40) : ", str.count(sub, 4, 40))
sub = "wow"
print("str.count(sub) : ", str.count(sub))
# 输出结果:
# str.count(sub, 4, 40) : 2
# str.count(sub) : 1
猜你喜欢:👇🏻
⭐【Python】break 和 continue 的用法
⭐【Python】去除列表中字符串里的所有符号
⭐【Python】find()函数居然还能指定搜索的起点和终点?