python2020-6-14笔记

    技术2024-11-13  10

    #统计某句英文句子中有多少某个字母字母

    def count_letter(s,letter):

        result=0

        for i in s:

            if i==letter:

                result+=1

        return result

    s="snwoosdjodmo"

    print("总共有%i个o" %count_letter(s,'o'))

    print("总共有%i个s" %count_letter(s,'s'))

    Processed: 0.028, SQL: 9