简体   繁体   English

configobj多种配置

[英]configobj multiple configurations

I am a new programmer working on a program that contains a list of recipes which can be searched and then generate menu from a selected commonality. 我是一名新程序员,正在研究一个程序,该程序包含可以搜索的食谱列表,然后根据选定的通用性生成菜单。

My initial thought has been to use a configuration file to store the data (I am using configobj for python). 我最初的想法是使用配置文件存储数据(我将configobj用于python)。 The problem here is that a value (eg ingredients = [] ) will occur several times. 这里的问题是一个值(例如, ingredients = [] )将出现几次。

Is there a way to separate different configurations within a single file? 有没有办法在一个文件中分离不同的配置? something like 就像是

Recipe
{
    value0 = 
}
Recipe 2
{
    value0 =
}

I am trying to avoid having ascending values ( value1(n),value1(n+1) ) or using a config file for each recipe. 我试图避免每个值都使用升序值( value1(n),value1(n+1) )或使用配置文件。

Alternatively if this is not possible, could someone suggest an alternative file structure, including those not using configobj . 或者,如果无法做到这一点,那么有人可以建议其他文件结构,包括那些不使用configobj文件结构。

If you want human-editable ini-like format: 如果您想要人类可编辑的类似ini的格式:

[Recipe]
value0 = ..

[Recipe2]
value0 = ..

If the file is used to exchange data between programs then you could use (also human-readable) json format: 如果该文件用于在程序之间交换数据,则可以使用(也是人类可读的)json格式:

{ "Recipe": { "value0": ".." }, "Recipe2": { "value0": ".." } }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM