轉自:https://www.runoob.com/python/att-string-count.htmlhtml
http://www.javashuo.com/article/p-twyctmat-gv.html(講解很是好)python
1.Python count() 方法用於統計字符串裏某個字符出現的次數。可選參數爲在字符串搜索的開始與結束位置。app
str.count(sub, start= 0,end=len(string))
>>> s="ai" >>> j="this is a love" >>> j.count(s) 0 >>> s='i' >>> j.count(s) 2
map()是 Python 內置的高階函數,它接收一個函數 f 和一個 list,並經過把函數 f 依次做用在 list 的每一個元素上,獲得一個新的 list 並返回。
函數語法:函數
map(function, iterable, ...)
一、當seq只有一個時,將函數func做用於這個seq的每一個元素上,並獲得一個新的seq。
由leetcode上的771題目學習的知識點,學習