我在将字典从一个列表传递到另一个函数时遇到了问题。我很肯定是因为我的字典在一系列字典中。你知道吗
示例:
我想要的是:{"part": x2f5, "color": red, "amount": 10}
传递给函数时得到的结果:[{part": x2f5, "color": red, "amount": 10}]
if (len(order["inventory"]) >= 1):
#I want to double check here if the part is already in the order
if new_order["part"] in (i["part"] for i in order["inventory"]):
if already_in(new_order, order["inventory"]):
如果我需要补充更多信息,请告诉我。你知道吗
你可以试试这个:
此解决方案将允许您将“n”个字典项从列表传递到
the_function
。你知道吗谢谢大家!你知道吗
不过,我自己也能解决这个问题,如果有人好奇的话,我就是这么做的
相关问题 更多 >
编程相关推荐