python 统计字符串中 某个字符的个数 format count 两个函数

python  统计字符串中 某个字符的个数

    def getCoutn(self, n):

        temp = format(n, "b")

        st = str(temp)        

        return st.count('1')

posted @ 2022-07-11 22:20  bH1pJ  阅读(70)  评论(0编辑  收藏  举报