码迷,mamicode.com
首页 > 其他好文 > 详细

一个关于字典的函数

时间:2017-10-24 00:17:46      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:else   一个   als   log   get   images   src   es2017   分享   

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)

 

 技术分享

一个关于字典的函数

标签:else   一个   als   log   get   images   src   es2017   分享   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!