当前位置: 代码迷 >> 综合 >> 出子串所有位置输
  详细解决方案

出子串所有位置输

热度:84   发布时间:2024-01-21 03:12:03.0
at_str = '@娃哈哈@萌萌挞@小机@小宝宝'pos = at_str.find('@')
count = 0while pos != -1:count - count+1print('@出现位善:{}'.format(pos))pos = at_str.find('@',pos + 1)print('@总共出现了{}次。'.format(count))print('@总共出现了{}次。'.format(at_str.count('@')))

  相关解决方案