我有一份单子,里面有一本词典。 mylist示例:
products = [{u'title': u'product_A', u'int': [{u'content': 8112, u'name': u'orbitnumber'}, {u'content': 107, u'name': u'relativeorbitnumber'}], u'double': {u'content': 23.4161, u'name': u'cloudcoverpercentage'}]
如果我想找到特定的项目,我使用“for循环”。 例如:
for i in range(len(products)):
unzip(products[i]["title"])
这段代码工作得很好。 现在,我想把这个列表作为参数传递给一个fresh函数。在
我如何定义那个可以以“products”列表为参数的函数?我知道在python中,您可以使用:*args作为参数传递一个列表。但是,如何在函数中以一般方式定义products[list_index][“key”]。在
我同意今天的说法。 另一种方法是: 1使用要更改或包含在词典中的参数定义词典
dictionary_treatment = your_function(dictionary)
对我有用!在
问候
你的函数是我的 您可以定义如下:
在另一个地方,你调用my_f function并将“products”作为my_f function的参数传递
^{pr2}$传递参数只是一种情况。 请注意,在python中,可以将任何内容作为参数传递
相关问题 更多 >
编程相关推荐