import os def word(filename, w): for item in os.listdir(filename): # 打开文件 print(item) s = 0 with open(os.path.join(filename, item), 'rb') as f: total = f.read().decode('utf-8') for line in total.split(): if w in line: s += 1 print(s) word('D:\python练习题\python实战', 'for')
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交