码迷,mamicode.com
首页 > 编程语言 > 详细

python 练习题

时间:2015-06-15 23:25:21      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

1.知道了一些图书的信息,找出其中最小的价格:

#!/usr/bin/python
books=[
        {"name":"abc","price":23.3,"store":u"xinhu"},
        {"name":"win","price":12.3,"store":"kk"},
        {"name":"kk","price":11,"store":"koko"},
        {"name":"linux","price":0.3,"store":"yamx"},                                                                                                          
]
res = min(item[x] for item in books for x in item if "price" == x)
print res      

 

python 练习题

标签:

原文地址:http://www.cnblogs.com/sky0917/p/4579326.html

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