class FileManager: def __init__(self): pass def write_file(self,file_path,write_type,content): ''' :param file_path: :param write_type: w-覆盖写,a-追加 :param content: :return: ''' with open(file_path,write_type,encoding="utf-8") as f: f.write(content) def read_file(self,file_path,read_type): ''' :param file_path: :param read_type: 1-全读返回,2--返回行list :return: ''' with open(file_path, "r", encoding="utf-8") as f: if read_type ==1: content = f.read() elif read_type ==2: content = f.readlines() else: content = "" return content