
请问这个错误类型是什么意思?要怎么修改内容 不是很懂关于这里?
注意:
import os
def findfiles(path, strkey):
filepathlist = []
txt = ""
dir_files = os.walk(path)
for toppath, subpath, fileslist in dir_files:
for file in fileslist:
if file[-4:] == ".txt":
file_path = os.path.join(toppath, file)
with open(file_path, "r", encoding="utf-8") as f:
txt = f.read()
if strkey in txt:
filepathlist.append(file_path)
return filepathlist
path = "/Users/apple/Desktop/python/python文件练习"
strkey = "沧海"
fileslist = findfiles(path, strkey)
print(fileslist)