一个关于字典的函数

时间:2017-10-23 23:58:59   收藏:0   阅读:341
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)

 

 技术分享

原文:http://www.cnblogs.com/dreamyu/p/7605857.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!