API
一、string 中 某字符 的次數
str.count(sub, start= 0,end=len(string))
Args | Annotations |
---|---|
sub | 搜索的子字符串 |
start | 字符串開始搜索的位置。默認為第一個字符,第一個字符索引值為0。 |
end | 字符串中結束搜索的位置。字符中第一個字符的索引為 0。默認為字符串的最后一個位置。 |
二、list 中 某元素 的次數
list.count(obj)
Args | Annotations |
---|---|
obj | 搜索的list |
實驗代碼
一、string 中 某字符 的次數
二、list 中 某元素 的次數
參考 https://blog.csdn.net/JNingWei/article/details/78308815