Python中的Matlab结构
python中是否有类似于Matlab结构的变量 我想在另一个结构中创建一个结构,就像在Matlab中一样,但是在Python中。 我已经查阅了Python字典,但还没有找到一种访问其值的简单方法。这在Matlab中非常简单 在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
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吗?