我有以下问题:
我有一个dict列表,想循环查看列表(临时列表),然后检查:
以下是包含列表和变量的数据:
distance_value = 1000
temp = [
{
"z": 1450,
"t1": 0,
"angle1": 90,
"material": "Balsa 150"
},
{
"z": 1950,
"t1": 25,
"angle1": 90,
"material": "Balsa 150"
},
{
"z": 12800,
"t1": 25,
"angle1": 90,
"material": "Balsa 150"
},
{
"z": 13000,
"t1": 15,
"angle1": 90,
"material": "Balsa 150"
},
{
"z": 25900,
"t1": 15,
"angle1": 90,
"material": "Balsa 150"
},
{
"z": 26000,
"t1": 10,
"angle1": 90,
"material": "Balsa 150"
}]
我找了很多问题,但找不到答案。 我希望我能把我的问题说清楚,有人能帮我。 提前多谢了。你知道吗
我真的不知道如何开始,但这是我的想法,我不能去工作:
distance_value = 1000
for dic in temp:
if "dic["z"] +1 (second element of the list) - dic["z"] < distance_value:
new_dic = {"z": (dic["z"]+1 - dic["z"]), "t1": dic["t1"] , "angle1":dic["angle1"], "material":dic["material"] }
temp.insert[dic["z"]+1, new_dic]
从我的json测试文件
test.json
:python代码:
我的输出:
逻辑如下:
Continue
Continue
条件来中断for循环(第一次出现时中断检查循环)Continue
为false,while循环中断相关问题 更多 >
编程相关推荐