写入文件 WriteFile path: 需要写入的文件路径 data: 需要写入的数据 return: 成功返回True or 失败返回False path: the file path that needs to be written data: data to be written return: Returns True or success or False on failure
(self, path, data)
| 9 | |
| 10 | class WriteReadFile(LoggerRecord): |
| 11 | def WriteFile(self, path, data) -> bool: |
| 12 | """ |
| 13 | 写入文件 |
| 14 | WriteFile |
| 15 | |
| 16 | path: 需要写入的文件路径 |
| 17 | data: 需要写入的数据 |
| 18 | return: 成功返回True or 失败返回False |
| 19 | |
| 20 | path: the file path that needs to be written |
| 21 | data: data to be written |
| 22 | return: Returns True or success or False on failure |
| 23 | """ |
| 24 | |
| 25 | try: |
| 26 | with open(path,'w',encoding='UTF-8') as w: |
| 27 | w.write(data) |
| 28 | return True |
| 29 | except Exception as e: |
| 30 | WriteReadFile.Custom_Write_logger(self,"",f"{os.getcwd()}/AiBotRunLOG/{time.strftime(r'%Y-%m-%d',time.localtime(time.time()))}/","SysModeError.log",False,"error",f"{traceback.format_exc()}") |
| 31 | return False |
| 32 | |
| 33 | def ReadFile(self,path) -> str or bool: |
| 34 | """ |
nothing calls this directly
no test coverage detected