1. 描述
count: 用于统计字符串里某一个字符串出现的次数。
可选参数:用于设置搜索字符串的开始和结束的位置
2. 语法
str.count(sub, start= 0,end=len(string))
3. 参数
sub:指定搜索的字符串
start:字符串开始搜索的位置,默认为第一个字符串,第一个字符串的索引为0
end:字符串中结束搜索的位置,默认是最后一个字符串
4. 返回值
返回指定字符串在该字符中出现的次数
5. 案例
app_name_list=['co_arg_app-DSdlb_SideView_', 'position_app-rtk_hook_th']
app_name_all_list=['co_arg_app-DSdlb_SideView_', 'position_app-rtk_hook_th', 'position_app-rtk_hook_th', 'position_app-rtk_hook_th']
for app_name1 in app_name_list:
number=app_name_all_list.count(app_name1)
print(f"{app_name1}:出现 {number} 次")