在Python中访问JIC到DICT

时间:2015-06-15 08:19:43

标签: python

我在JS中有下一个JSON

var intervalos= {
          "operandos":[{
             "extremoInferior":$(edit_numvar).context.value,
             "extremoSuperior":$(edit_numvar2).context.value
          },
          {
             "extremoInferior":$(edit_numvar3).context.value,
             "extremoSuperior":$(edit_numvar4).context.value
          }]
};

我做了parsed_input = json.loads(self.intervalos)

但现在我不知道如何访问我的词典。我试过

intervalos[operandos][extremoInferior])     

但它会返回错误。

你能帮助我访问我的dict中的任何元素吗?

3 个答案:

答案 0 :(得分:2)

将JSON反序列化为Python对象后,您只需访问元素即可。例如:

 <Button
    android:id="@+id/TestButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAllCaps="false"
    android:text="ExaMple" />

答案 1 :(得分:2)

请尝试以下代码:

if [[ "010" < "01." ]]; then echo "Wrong"; else echo "OK"; fi
if [[ "010" < "01.0" ]]; then echo "Wrong"; else echo "OK"; fi
if [ "010" \< "01." ]; then echo "Wrong"; else echo "OK"; fi
if [ "010" \< "01.0" ]; then echo "Wrong"; else echo "OK"; fi

答案 2 :(得分:-2)

intervalos['operandos'][0]['extremoInferior']

intervalos['operandos'][1]['extremoInferior']

intervalos['operandos']被定义为其中两个对象的数组。