# -*- coding:utf-8 -*-from setting import *import osimport sys# print(DATA_DIR)class DataManage(): ‘‘‘数据的存储和读取‘‘‘ def __init__(self,): sys.path.append(DATA_DIR) def dataWrite(self, file, value): ‘‘‘ 数据的存储 :param file: 文件路径 :param value: 输入的内容 :return: ‘‘‘ file = os.path.join(DATA_DIR, file) with open(file, ‘w‘) as f: f.write(value) # print(‘数据存储目录:%s‘%file) def dataRead(self, file): ‘‘‘ 读取数据 :param file: 文件路径 :return: 得到一个读取文件全部内容的list ‘‘‘ try: file = os.path.join(DATA_DIR, file) with open(file, ‘r‘) as f: data = f.readlines() return data except FileNotFoundError as e: print(e)if __name__ == ‘__main__‘: file = ‘doorTicket\orange.datas‘ data = DataManage() data.dataWrite(file=file, value=‘world‘) res = data.dataRead(file) print(res)