count()

count() 用于统计指定元素在序列中出现的次数,字符串 、元组 、列表都属于序列

In [1]: str = "hello world"

In [2]: str.count('l')
Out[2]: 3

 

 

 

 

    

posted @ 2018-12-27 18:17  孔雀东南飞  阅读(286)  评论(0编辑  收藏  举报