You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
789 B

2 months ago
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