读取YAML文件。 参数: - file_path (str): 文件路径。 - encoding (str): 文件编码格式,默认为 'utf-8'。 返回: - dict: 读取的YAML文件内容。
(file_path, encoding='utf-8')
| 247 | return json.load(f) |
| 248 | |
| 249 | def read_yaml(file_path, encoding='utf-8'): |
| 250 | """ |
| 251 | 读取YAML文件。 |
| 252 | |
| 253 | 参数: |
| 254 | - file_path (str): 文件路径。 |
| 255 | - encoding (str): 文件编码格式,默认为 'utf-8'。 |
| 256 | |
| 257 | 返回: |
| 258 | - dict: 读取的YAML文件内容。 |
| 259 | """ |
| 260 | with open(file_path, 'r', encoding=encoding) as f: |
| 261 | logger.info(f"读取YAML文件: {file_path}") |
| 262 | return yaml.safe_load(f) |
| 263 | |
| 264 | |
| 265 | def read_xlsx(file_path, encoding='utf-8'): |