例子:
class FileTool:
def __init__(self, filepath):
self.filepath = filepath
def write_to_file(self, line):
f = open(self.filepath, 'a')
f.write(line)
f.close()
def read_to_file(self):
f = open(self.filepath, 'r')
lines = f.readlines()
f.close()
return lines