亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    python中count函數(shù)的用法詳解

    python中count函數(shù)的用法詳解

    python中count函數(shù)的用法

    count()函數(shù)

    描述:統(tǒng)計字符串里某個字符出現(xiàn)的次數(shù),可以選擇字符串索引的起始位置和結束位置。

    語法:str.count("char", start,end) str.count("char")

    返回值:整型

    參數(shù)說明:

    str —— 要統(tǒng)計的字符(可以是單字符,也可以是多字符)

    star —— 索引字符串的起始位置,默認參數(shù)為0

    end —— 索引字符串的結束位置,默認參數(shù)為字符串長度即len(str)

    程序示例:

    str = "i love python,i am learning python" print(str.count("i")) #star 和end 為默認參數(shù) print(str.count("i",2)) # star值為2,end值為默認參數(shù) print(str.count("i",2,5)) #star值為2,end值為5 print(str.count("am"))  #多字符統(tǒng)計

    程序運行結果:

    3 2 0

    推薦學習:Python教程

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號