python 练习题

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      

 

posted @ 2015-06-15 21:48  sky0917  阅读(174)  评论(0编辑  收藏  举报