网站建设开发电销话术网站建设怎么选择MySQL数据库大小
1.利用yaml库可以进行参数的保存
def update_yaml_file(self,file_path, updates):"""修改 YAML 文件的部分内容,保持其他条目不变:param file_path: YAML 文件路径:param updates: 需要更新的键值对(字典)"""# 读取原始文件内容if not os.path.exists(file_path):data={}else:with open(file_path, 'r+', encoding='utf-8') as f:data = yaml.safe_load(f) or {} # 如果文件为空,初始化为空字典# 仅更新指定的键,保持其他键不变data.update(updates)# 写回文件(保持原格式和注释)with open(file_path, 'w+', encoding='utf-8') as f:yaml.dump(data, f, allow_unicode=True, sort_keys