转自:https://www.runoob.com/python/att-string-count.html
https://www.cnblogs.com/lincappu/p/8179475.html(讲解非常好)
1.Python count() 方法用于统计字符串里某个字符出现的次数。可选参数为在字符串搜索的开始与结束位置。
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
2.map方法
map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回。
函数语法:
map(function, iterable, ...)
1、当seq只有一个时,将函数func作用于这个seq的每个元素上,并得到一个新的seq。
由leetcode上的771题目学习的知识点,