读取JSON文件。 参数: - file_path (str): 文件路径。 - encoding (str): 文件编码格式,默认为 'utf-8'。 返回: - dict: 读取的JSON文件内容。
(file_path, encoding='utf-8')
| 232 | |
| 233 | |
| 234 | def read_json(file_path, encoding='utf-8'): |
| 235 | """ |
| 236 | 读取JSON文件。 |
| 237 | |
| 238 | 参数: |
| 239 | - file_path (str): 文件路径。 |
| 240 | - encoding (str): 文件编码格式,默认为 'utf-8'。 |
| 241 | |
| 242 | 返回: |
| 243 | - dict: 读取的JSON文件内容。 |
| 244 | """ |
| 245 | with open(file_path, 'r', encoding=encoding) as f: |
| 246 | logger.info(f"读取JSON文件: {file_path}") |
| 247 | return json.load(f) |
| 248 | |
| 249 | def read_yaml(file_path, encoding='utf-8'): |
| 250 | """ |