#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@文件        :findstr.py
@说明        :
@时间        :2021/07/08 10:29:37
@作者        :shitao.li
@版本        :1.0
'''

def findStr(str):
    with open("a.txt",'r') as f:
        counts = 0
        for line in f.readlines():
            time = line.count(str)
            counts += time
        print("%s出现的次数:%d"%(str,counts))

findStr(",")

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐