标签: python string performance
我知道有多种方法可以计算字符串中字符的实例,例如使用 count()、collections.Counter、regex 等,但是如果我只使用哪种方法最有效想在字符串中查找某个特定字符的实例?
count()
collections.Counter
答案 0 :(得分:0)
Count 是最快和最简单的版本 tbh。你应该坚持:)