在字典列表中形成字典列表理解

时间:2015-10-12 18:32:24

标签: python json python-3.x dictionary

我有一个webservice json响应,它是一个字典列表,值本身就是字典。如下例所示:

echo spider(FALSE, FALSE, 'https://www.google.com/ncr');

我有以下哪些有用,我只是想知道是否有办法用列表理解来做到这一点?

Array
(
[url] => https://www.google.com/
[content_type] => text/html; charset=UTF-8
[http_code] => 200
[header_size] => 1665
[request_size] => 701
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 1
[total_time] => 2.215
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 9024
[speed_download] => 4074
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0.437
[redirect_time] => 1.7
[certinfo] => Array
    (
    )

[redirect_url] => 
)

1 个答案:

答案 0 :(得分:3)

我认为这就是你要找的东西?

[ values['daily_process'] for items in parsed_response 
                              for values in items.values() ]