读取文件 ReadFile path: 需要读取的文件路径 return: 成功返回文件数据, 失败返回False path: the file path to be read return: file data is returned successfully, and False is returned if it fails
(self,path)
| 31 | return False |
| 32 | |
| 33 | def ReadFile(self,path) -> str or bool: |
| 34 | """ |
| 35 | 读取文件 |
| 36 | ReadFile |
| 37 | |
| 38 | path: 需要读取的文件路径 |
| 39 | return: 成功返回文件数据, 失败返回False |
| 40 | |
| 41 | path: the file path to be read |
| 42 | return: file data is returned successfully, and False is returned if it fails |
| 43 | """ |
| 44 | |
| 45 | try: |
| 46 | with open(path,'r',encoding='UTF-8') as r: |
| 47 | Data = r.read() |
| 48 | return Data |
| 49 | except Exception as e: |
| 50 | 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()}") |
| 51 | return False |
| 52 | |
| 53 | def WriteFileAddTo(self,path,data) -> bool: |
| 54 | """ |
no test coverage detected