一个关于字典的函数

Posted 不当咸鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一个关于字典的函数相关的知识,希望对你有一定的参考价值。

def cakes(recipe, available):
    d = [False for recipe_key in recipe.keys() if recipe_key not in available.keys()]
    if d:
       return 0
    else:
       return min([available[recipe_key]/recipe[recipe_key] for recipe_key in recipe.keys()])

 

def cakes(recipe, available):
  return min(available.get(k, 0)/recipe[k] for k in recipe)

 

 

以上是关于一个关于字典的函数的主要内容,如果未能解决你的问题,请参考以下文章

关于代码片段的时间复杂度

几个关于js数组方法reduce的经典片段

几个关于js数组方法reduce的经典片段

七十一:flask钩子函数之关于context_processor的钩子函数

一个关于字典的函数

Python snippet(代码片段)