python:count 函数

API

一、string 中 某字符 的次数

str.count(sub, start= 0,end=len(string))

ArgsAnnotations
sub 搜索的子字符串
start 字符串开始搜索的位置。默认为第一个字符,第一个字符索引值为0。
end 字符串中结束搜索的位置。字符中第一个字符的索引为 0。默认为字符串的最后一个位置。

二、list 中 某元素 的次数

list.count(obj)

ArgsAnnotations
obj 搜索的list

 

实验代码

一、string 中 某字符 的次数

 

二、list 中 某元素 的次数

 

参考 https://blog.csdn.net/JNingWei/article/details/78308815

posted @ 2018-08-29 10:35  Lemon_Rain  阅读(2296)  评论(0编辑  收藏  举报