后面的yield和close能否跟前面的for对齐?
class loadFiles(object): def __init__(self,par_path): self.par_path = par_path def __iter__(self): folders = loadFolders(self.par_path) for folder in folders: # 1 level directory catg = folder.split(os.sep)[-1] #sep是用来分隔分隔符的 for file in os.listdir(folder): # secondary directory file_path = os.path.join(folder,file) # 读取文本的具体操作 if os.path.isfile(file_path): this_file = open(file_path,'rb') # rb(二进制)读取更快 content = this_file.read().decode('utf-8') # print(catg,file)