MCPcopy Create free account
hub / github.com/a943512/PyAibote / ReadFile

Method ReadFile

PyAibote/Tool/WriteReadFileFunc.py:33–51  ·  view source on GitHub ↗

读取文件 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)

Source from the content-addressed store, hash-verified

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 """

Callers 1

ReadJsonFileMethod · 0.95

Calls 1

Custom_Write_loggerMethod · 0.80

Tested by

no test coverage detected