English 中文(简体)
随着进度的推移,逐步建立一套记录
原标题:Building a set of records incrementally as app progresses

我有一部精彩的CLI仪器,从一只conf子中读写。 我不能改变下文的汇辑格式。

TYPE_A = "value1,value2,value2"
TYPE_A = "value3,value4,value5"
TYPE_B = "valuex,valuey,valuez"

根据<代码>TYPE,I ll需要做一些初步处理。 在我为大家采取这一步骤之后,我需要做一些额外的处理,并视所选择的印刷国家和打算采取的行动或执行这些行动的办法而定。

我愿将会议初步分为一个字典,并更新所有的相关内容。 然后,要么印刷全部状态,要么执行行动(或者如果情况不正确,失败)

我的想法是:

dict
    TYPE_A_list
        dict_A[0] key:value,key:value,key:value
        dict_A[1] key:value,key:value,key:value
    TYPE_B_list
        dict_A[0] key:value,key:value,key:value
        dict_A[1] key:value,key:value,key:value

我认为,我想把这段话读作,然后加上关键和价值观,或更新价值,作为评估进展,并重新处理每组别。

最后,我的问题。

  1. I m not sure how iterate over each list of dicts or to add list elements and add or update key:value pairs.
  2. Is what I describe above the best way to go about this?

我对沙尔说得很新,因此,我可以提出任何建议。 FWIW,这将是第2.6页。

A little clarification on the config file lines

    CAR_TYPE = "Ford,Mustang,Blue,2005"
    CAR_TYPE = "Honda,Accord,Green,2009"
    BIKE_TYPE = "Honda,VTX,Black,2006"
    BIKE_TYPE = "Harley,Sportster,Red,2010"
    TIRE_TYPE = "170R15,whitewall"
    
Each type will have the same order and number of values.
问题回答

不需要“再分配”两种不同的<代码>TYPE_A转让——你可以合并。

TYPE_A = "value1,value2,value2"
TYPE_A = "value3,value4,value5"

只有在其中一方,或者两者都取决于你们的慈善机构的执行情况。

然后,数据模型应当:

dict
    TYPE_A: list(value1, value2, value3)
    TYPE_B: list(valuex, valuey, valuez)

这样,你就可以很容易地通过<代码>字典>(<>>>>>项目/代码>进行检索:

for _type, values in dict.items():
    for value in values:
        print "%s: %s" % (_type, value)
        # or whatever you wish to do




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签