在Python中,`count` 是一个内置函数,用于统计序列(如列表、元组或字符串)中某个元素出现的次数。以下是 `count` 函数的基本用法:
对于字符串,`count` 方法用于统计指定子串出现的次数。语法为 `string.count(substring, start=0, end=len(string))`。
对于列表或元组,`count` 方法用于统计指定元素出现的次数。语法为 `sequence.count(element)`。
对于字符串,`count` 方法还可以选择搜索的起始和结束位置,语法为 `str.count(sub, start, end)`。
`count` 函数返回一个整数,表示指定元素在序列中出现的次数。
---