码迷,mamicode.com
首页 > 其他好文 > 详细

count

时间:2019-11-16 16:09:26      阅读:68      评论:0      收藏:0      [点我收藏+]

标签:nbsp   img   loading   use   style   strong   star   src   单个字符   

str.count(x, _start, _end)

x:需要查找的字符串(包含单个字符)。

_start:查找开始的位置,默认为0,也就是str开始的位置。

_end:查找结束的位置,默认为-1,也就是str结束的位置。

 

sentence = I can because I think I can
n1 = sentence.count(i)
n2 = sentence.count(can)

print(n1, n1)
print(n2, n2)

技术图片

 

count

标签:nbsp   img   loading   use   style   strong   star   src   单个字符   

原文地址:https://www.cnblogs.com/qianslup/p/11828947.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!