如何找出包含两个冒号的字符串 python

如题所述

使用count函数

>>> s  ='sf:sdfs:sfs'
>>> s.count(':')
2
>>> if s.count(':') == 2:
    print('s åŒ…含两个冒号')

s åŒ…含两个冒号

温馨提示:答案为网友推荐,仅供参考