Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python中的Matlab结构_Python_Matlab_Dictionary_Structure - Fatal编程技术网

Python中的Matlab结构

Python中的Matlab结构,python,matlab,dictionary,structure,Python,Matlab,Dictionary,Structure,python中是否有类似于Matlab结构的变量 我想在另一个结构中创建一个结构,就像在Matlab中一样,但是在Python中。 我已经查阅了Python字典,但还没有找到一种访问其值的简单方法。这在Matlab中非常简单 在Matlab中,我将执行以下操作: 创建结构 structure.parent1.variable1 = 23; structure.parent1.variable2 = 19; structure.parent1.variable3 = 19; structure.p

python中是否有类似于Matlab结构的变量

我想在另一个结构中创建一个结构,就像在Matlab中一样,但是在Python中。 我已经查阅了Python字典,但还没有找到一种访问其值的简单方法。这在Matlab中非常简单

在Matlab中,我将执行以下操作:

创建结构

structure.parent1.variable1 = 23;
structure.parent1.variable2 = 19;
structure.parent1.variable3 = 19;
structure.parent2.variable1 = 10;
structure.parent2.variable2 = 11;

structure = 

    parent1: [1x1 struct]
    parent2: [1x1 struct]
然后访问变量,只需tipying

structure.parent2.variable1

ans =

    10

python中的词典有什么问题-要创建并访问它们:

structure = {}
structure["parent1"] = {}
structure["parent1"]["variable1"] = 23;
structure["parent1"]["variable2"] = 19;
structure["parent1"]["variable3"] = 19;
structure["parent2"] = {}
structure["parent2"]["variable1"] = 10;
structure["parent2"]["variable2"] = 11;

python中的词典有什么问题-要创建并访问它们:

structure = {}
structure["parent1"] = {}
structure["parent1"]["variable1"] = 23;
structure["parent1"]["variable2"] = 19;
structure["parent1"]["variable3"] = 19;
structure["parent2"] = {}
structure["parent2"]["variable1"] = 10;
structure["parent2"]["variable2"] = 11;

使用字典可以访问如下元素

structure['parent2']['variable1']

使用字典可以访问如下元素

structure['parent2']['variable1']

你考虑过使用Python吗?你考虑过使用Python吗?