Json 在Python字典中查找特定值的最有效方法是什么?

Json 在Python字典中查找特定值的最有效方法是什么?,json,python-3.x,dictionary,key,Json,Python 3.x,Dictionary,Key,我正在构建一个接收json格式API响应的小应用程序。我已经编写了一些代码来访问我需要的数据,但它似乎效率很低。如果有人能提供更好的方法来访问json响应中的所有“title”键:值对,我将不胜感激 再次感谢您在这上面花费的时间 我的代码是: results = call_api(keywords) for key_info, value_info in results.items(): print("Key_Info: ", key_info) for

我正在构建一个接收json格式API响应的小应用程序。我已经编写了一些代码来访问我需要的数据,但它似乎效率很低。如果有人能提供更好的方法来访问json响应中的所有“title”键:值对,我将不胜感激

再次感谢您在这上面花费的时间

我的代码是:

results = call_api(keywords)
    for key_info, value_info in results.items():
        print("Key_Info: ", key_info)
        for key in value_info:
            for k, v in key.items():
                print("K: ", k)
                if k == 'searchResult':
                    for key_v in v:
                        for kv, val in key_v.items():
                            if kv == 'item':
                                print("Items: '\n'", val)
                                for key_v1 in val:
                                    for kv1, val1 in key_v1.items():
                                        if kv1 == 'title':
                                            print("Val1: ", val1)
json响应是:

results = [{'ack': ['Success'], 'version': ['1.13.0'], 'timestamp': ['2020-04-01T15:36:40.081Z'], 'searchResult': [{'@count': '100', 'item': [{'itemId': ['184203717563'], 'title': ['iPhone 11 64gb Unlocked Space Gray'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['42425'], 'categoryName': ['Other Cell Phone Accessories']}], 'galleryURL': ['https://thumbs4.ebaystatic.com/m/m4H-uJhU8djYqGjngaOsGKg/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/iPhone-11-64gb-Unlocked-Space-Gray-/184203717563'], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'postalCode': ['112**'], 'location': ['Brooklyn,NY,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '0.0'}], 'shippingType': ['Free'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['2']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '70.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '70.0'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['true'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-03-09T11:58:35.000Z'], 'endTime': ['2020-03-09T12:10:09.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false']}], 'returnsAccepted': ['true'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['264635583783'], 'title': ['Apple iPhone 11 - 64GB - White (T-Mobile) A2111 (CDMA + GSM) Unlocked'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs4.ebaystatic.com/m/mw7SSMGB7_H70hn9PFarppg/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Apple-iPhone-11-64GB-White-T-Mobile-A2111-CDMA-GSM-Unlocked-/264635583783'], 'productId': [{'@type': 'ReferenceID', '__value__': '18034218100'}], 'paymentMethod': ['PayPal'], 'autoPay': ['false'], 'postalCode': ['175**'], 'location': ['Mount Joy,PA,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '7.35'}], 'shippingType': ['Flat'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['0']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '175.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '175.0'}], 'bidCount': ['1'], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['false'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-02-15T15:08:18.000Z'], 'endTime': ['2020-02-15T15:21:48.000Z'], 'listingType': ['Auction'], 'gift': ['false']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['153818145594'], 'title': ['Apple iPhone 11 - 64GB - White (Unlocked) A2111 (CDMA + GSM)'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs3.ebaystatic.com/m/mHN8ML_8zjcgP3ek6WXzKDg/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Apple-iPhone-11-64GB-White-Unlocked-A2111-CDMA-GSM-/153818145594'], 'productId': [{'@type': 'ReferenceID', '__value__': '10034217463'}], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'location': ['Venezuela'], 'country': ['VE'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '0.0'}], 'shippingType': ['Free'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['5']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '225.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '225.0'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['false'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-02-01T20:10:45.000Z'], 'endTime': ['2020-02-01T22:33:43.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false'], 'watchCount': ['13']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['402178640885'], 'title': ['Apple iPhone 11 - 64GB - Purple (Unlocked) A2111 (CDMA + GSM)'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs2.ebaystatic.com/m/mYCV1TIZkgMPngU4PTX0GZA/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Apple-iPhone-11-64GB-Purple-Unlocked-A2111-CDMA-GSM-/402178640885'], 'productId': [{'@type': 'ReferenceID', '__value__': '26034221296'}], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'postalCode': ['482**'], 'location': ['Detroit,MI,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '0.0'}], 'shippingType': ['Free'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['true'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['3']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '250.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '250.0'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['true'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-03-23T08:30:54.000Z'], 'endTime': ['2020-03-23T08:34:46.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['352974118975'], 'title': ['IPHONE 11 64GB MOTHERBOARD UNLOCKED CLEAN IMEI PARTIALLY RIPPED RIBBON READ'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['43304'], 'categoryName': ['Cell Phone & Smartphone Parts']}], 'galleryURL': ['https://thumbs4.ebaystatic.com/m/mNIgcHzs0hLLWTa23Tuz4-Q/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/IPHONE-11-64GB-MOTHERBOARD-UNLOCKED-CLEAN-IMEI-PARTIALLY-RIPPED-RIBBON-READ-/352974118975'], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'postalCode': ['295**'], 'location': ['Murrells Inlet,SC,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '9.99'}], 'shippingType': ['Flat'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['1']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '269.99'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '269.99'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['false'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-02-17T03:39:17.000Z'], 'endTime': ['2020-02-19T04:47:43.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false'], 'watchCount': ['1']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['133357520366'], 'title': ['Apple iPhone 11 - 64GB - White (Unlocked) A2111 (CDMA + GSM) (CA)'], 'globalId': ['EBAY-ENCA'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs3.ebaystatic.com/m/mEMmeMv1O9-oVAJh2pIPG7w/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Apple-iPhone-11-64GB-White-Unlocked-A2111-CDMA-GSM-CA-/133357520366'], 'productId': [{'@type': 'ReferenceID', '__value__': '18034218058'}], 'paymentMethod': ['PayPal'], 'autoPay': ['false'], 'postalCode': ['M4B2E8'], 'location': ['Canada'], 'country': ['CA'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '14.05'}], 'shippingType': ['Flat'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['1']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'CAD', '__value__': '400.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '281.03'}], 'bidCount': ['1'], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['false'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-03-11T00:13:33.000Z'], 'endTime': ['2020-03-11T01:20:44.000Z'], 'listingType': ['Auction'], 'gift': ['false'], 'watchCount': ['1']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['333552106846'], 'title': ['iphone 11 unlocked 64gb used'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['42425'], 'categoryName': ['Other Cell Phone Accessories']}], 'galleryURL': ['https://thumbs3.ebaystatic.com/m/mE1t8mWRhRzLghUUUj9DwVw/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/iphone-11-unlocked-64gb-used-/333552106846'], 'paymentMethod': ['PayPal'], 'autoPay': ['false'], 'postalCode': ['482**'], 'location': ['Detroit,MI,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '0.0'}], 'shippingType': ['Free'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['3']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '300.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '300.0'}], 'bidCount': ['1'], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['false'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-03-20T03:11:15.000Z'], 'endTime': ['2020-03-20T03:20:26.000Z'], 'listingType': ['Auction'], 'gift': ['false']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['383375527874'], 'title': ['Apple iPhone 11 (PRODUCT)RED - 64GB (Unlocked) A2111 (CDMA + GSM)'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['42425'], 'categoryName': ['Other Cell Phone Accessories']}], 'galleryURL': ['https://thumbs3.ebaystatic.com/m/m-YgOxEGl4iUroSqDYjzxaw/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Apple-iPhone-11-PRODUCT-RED-64GB-Unlocked-A2111-CDMA-GSM-/383375527874'], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'postalCode': ['361**'], 'location': ['Montgomery,AL,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '0.0'}], 'shippingType': ['Free'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['3']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '339.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '339.0'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['true'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-01-17T04:55:00.000Z'], 'endTime': ['2020-01-17T17:03:17.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false'], 'watchCount': ['1']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['352953066492'], 'title': ['IPHONE 11 64GB MOTHERBOARD UNLOCKED CLEAN IMEI FULLY FUNCTIONAL READY TO GO'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['43304'], 'categoryName': ['Cell Phone & Smartphone Parts']}], 'galleryURL': ['https://thumbs1.ebaystatic.com/m/mNIgcHzs0hLLWTa23Tuz4-Q/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/IPHONE-11-64GB-MOTHERBOARD-UNLOCKED-CLEAN-IMEI-FULLY-FUNCTIONAL-READY-GO-/352953066492'], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'postalCode': ['295**'], 'location': ['Murrells Inlet,SC,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '9.99'}], 'shippingType': ['Flat'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['1']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '349.99'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '349.99'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['false'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-01-30T02:33:34.000Z'], 'endTime': ['2020-02-14T22:40:47.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false'], 'watchCount': ['4']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['333533705928'], 'title': ['Apple iPhone 11 - 64GB - White (Unlocked) A2111 (CDMA + GSM)'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs1.ebaystatic.com/m/m2kd2VImUhpun-u2FbmU5nQ/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Apple-iPhone-11-64GB-White-Unlocked-A2111-CDMA-GSM-/333533705928'], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'postalCode': ['920**'], 'location': ['Carlsbad,CA,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '0.0'}], 'shippingType': ['Free'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['true'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['3']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '360.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '360.0'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['true'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-03-03T00:24:06.000Z'], 'endTime': ['2020-03-03T00:28:42.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['392659039983'], 'title': ['Apple iPhone 11 Pro Max - 64GB - Midnight\xa0Green (Unlocked) A2161 (CDMA + GSM)'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs4.ebaystatic.com/m/m1eY5Bm_2mpBYzlbEaZ-3VA/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Apple-iPhone-11-Pro-Max-64GB-Midnight-Green-Unlocked-A2161-CDMA-GSM-/392659039983'], 'productId': [{'@type': 'ReferenceID', '__value__': '15034218378'}], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'postalCode': ['703**'], 'location': ['Houma,LA,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '5.0'}], 'shippingType': ['Flat'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['3']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '360.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '360.0'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['true'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-01-28T08:40:19.000Z'], 'endTime': ['2020-01-28T08:52:00.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false'], 'watchCount': ['1']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['353001138954'], 'title': ['Apple iPhone 11 (PRODUCT)RED - 64GB (Verizon) A2111 (CDMA + GSM) ( Unlocked)'], 'globalId': ['EBAY-US'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs3.ebaystatic.com/m/mZIOUjWvHoH3lkaFBgu89oQ/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Apple-iPhone-11-PRODUCT-RED-64GB-Verizon-A2111-CDMA-GSM-Unlocked-/353001138954'], 'productId': [{'@type': 'ReferenceID', '__value__': '12034199377'}], 'paymentMethod': ['PayPal'], 'autoPay': ['false'], 'postalCode': ['212**'], 'location': ['Baltimore,MD,USA'], 'country': ['US'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '0.0'}], 'shippingType': ['FreePickup'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['true'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['3']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'USD', '__value__': '380.0'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '380.0'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['false'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-03-12T15:41:54.000Z'], 'endTime': ['2020-03-13T19:46:25.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false'], 'watchCount': ['19']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['114151310817'], 'title': ['Iphone 11 Black 64 Gb Factory Unlock IC LOCKED'], 'globalId': ['EBAY-ENCA'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs2.ebaystatic.com/m/mndjP5XVd3n7cVqP2a8PMDw/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Iphone-11-Black-64-Gb-Factory-Unlock-IC-LOCKED-/114151310817'], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'location': ['Canada'], 'country': ['CA'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '24.06'}], 'shippingType': ['Flat'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['1']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'CAD', '__value__': '529.95'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '372.33'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['true'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-03-16T21:35:57.000Z'], 'endTime': ['2020-03-17T19:43:42.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false'], 'watchCount': ['4']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, {'itemId': ['114160010197'], 'title': ['Iphone 11 Black 64 Gb Factory Unlock IC LOCKED'], 'globalId': ['EBAY-ENCA'], 'primaryCategory': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones']}], 'galleryURL': ['https://thumbs2.ebaystatic.com/m/mndjP5XVd3n7cVqP2a8PMDw/140.jpg'], 'viewItemURL': ['https://www.ebay.com/itm/Iphone-11-Black-64-Gb-Factory-Unlock-IC-LOCKED-/114160010197'], 'paymentMethod': ['PayPal'], 'autoPay': ['true'], 'location': ['Canada'], 'country': ['CA'], 'shippingInfo': [{'shippingServiceCost': [{'@currencyId': 'USD', '__value__': '24.06'}], 'shippingType': ['Flat'], 'shipToLocations': ['Worldwide'], 'expeditedShipping': ['false'], 'oneDayShippingAvailable': ['false'], 'handlingTime': ['1']}], 'sellingStatus': [{'currentPrice': [{'@currencyId': 'CAD', '__value__': '529.95'}], 'convertedCurrentPrice': [{'@currencyId': 'USD', '__value__': '372.33'}], 'sellingState': ['EndedWithSales']}], 'listingInfo': [{'bestOfferEnabled': ['true'], 'buyItNowAvailable': ['false'], 'startTime': ['2020-03-26T16:49:15.000Z'], 'endTime': ['2020-03-27T02:38:16.000Z'], 'listingType': ['FixedPrice'], 'gift': ['false'], 'watchCount': ['5']}], 'returnsAccepted': ['false'], 'condition': [{'conditionId': ['3000'], 'conditionDisplayName': ['Used']}], 'isMultiVariationListing': ['false'], 'topRatedListing': ['false']}, 'categoryHistogramContainer': [{'categoryHistogram': [{'categoryId': ['15032'], 'categoryName': ['Cell Phones & Accessories'], 'count': ['1161'], 'childCategoryHistogram': [{'categoryId': ['9355'], 'categoryName': ['Cell Phones & Smartphones'], 'count': ['1098']}, {'categoryId': ['9394'], 'categoryName': ['Cell Phone Accessories'], 'count': ['57']}, {'categoryId': ['43304'], 'categoryName': ['Cell Phone & Smartphone Parts'], 'count': ['6']}]}, {'categoryId': ['619'], 'categoryName': ['Musical Instruments & Gear'], 'count': ['1'], 'childCategoryHistogram': [{'categoryId': ['3858'], 'categoryName': ['Guitars & Basses'], 'count': ['1']}]}]}], 'aspectHistogramContainer': [{'domainDisplayName': ['Cell Phones & Smartphones'], 'aspect': [{'@name': 'RAM', 'valueHistogram': [{'@valueName': '16 GB', 'count': ['1']}, {'@valueName': '3 GB', 'count': ['4']}, {'@valueName': '4 GB', 'count': ['70']}, {'@valueName': '6 GB', 'count': ['1']}, {'@valueName': '7 GB', 'count': ['1']}, {'@valueName': '8 GB', 'count': ['1']}, {'@valueName': 'Not Specified', 'count': ['1084']}]}, {'@name': 'Features', 'valueHistogram': [{'@valueName': '3D Depth Camera', 'count': ['12']}, {'@valueName': '3D Depth Sensor', 'count': ['11']}, {'@valueName': '4K Video Recording', 'count': ['971']}, {'@valueName': 'Accelerometer', 'count': ['13']}, {'@valueName': 'Active Edge', 'count': ['4']}, {'@valueName': 'Ambient Light Sensor', 'count': ['12']}, {'@valueName': 'AMOLED Display', 'count': ['8']}, {'@valueName': 'ANT+', 'count': ['3']}, {'@valueName': 'Apple Care', 'count': ['3']}, {'@valueName': 'Barometer', 'count': ['2']}, {'@valueName': 'Bluetooth Enabled', 'count': ['7']}, {'@valueName': 'Camera', 'count': ['25']}, {'@valueName': 'Digital Compass', 'count': ['4']}, {'@valueName': 'Dual Rear Cameras', 'count': ['396']}, {'@valueName': 'Dust-Resistant', 'count': ['950']}, {'@valueName': 'EDGE', 'count': ['4']}, {'@valueName': 'Email, Web', 'count': ['2']}, {'@valueName': 'eSIM', 'count': ['962']}, {'@valueName': 'Facial Recognition', 'count': ['965']}, {'@valueName': 'Fast Charging', 'count': ['965']}, {'@valueName': 'Fast Wireless Charging', 'count': ['961']}, {'@valueName': 'Front Camera', 'count': ['2']}, {'@valueName': 'Geotagging', 'count': ['4']}, {'@valueName': 'Global Ready', 'count': ['2']}, {'@valueName': 'GPS', 'count': ['3']}, {'@valueName': 'Gyro Sensor', 'count': ['2']}, {'@valueName': 'HDR Display', 'count': ['569']}, {'@valueName': 'Internet Connectivity', 'count': ['2']}, {'@valueName': 'NFC Connectivity', 'count': ['1']}, {'@valueName': 'Night Mode', 'count': ['1']}, {'@valueName': 'OLED Display', 'count': ['568']}, {'@valueName': 'Proximity Sensor', 'count': ['2']}, {'@valueName': 'Rear Camera', 'count': ['12']}, {'@valueName': 'Retina Display', 'count': ['6']}, {'@valueName': 'Sim Free', 'count': ['1']}, {'@valueName': 'Speakerphone', 'count': ['4']}, {'@valueName': 'Telephoto Lens', 'count': ['568']}, {'@valueName': 'Touch Screen', 'count': ['7']}, {'@valueName': 'Triple Rear Camera', 'count': ['567']}, {'@valueName': 'Ultra Wide-Angle Camera', 'count': ['964']}, {'@valueName': 'Water-Resistant', 'count': ['968']}, {'@valueName': 'Wide-Angle Camera', 'count': ['964']}, {'@valueName': 'Wi-Fi Capable', 'count': ['3']}, {'@valueName': 'Wireless Charging', 'count': ['763']}]}, {'@name': 'Screen Size', 'valueHistogram': [{'@valueName': '5.5 - 5.9 in', 'count': ['202']}, {'@valueName': '6 in or More', 'count': ['557']}, {'@valueName': 'Not Specified', 'count': ['183']}]}, {'@name': 'Connectivity', 'valueHistogram': [{'@valueName': '2G', 'count': ['1']}, {'@valueName': '3G', 'count': ['5']}, {'@valueName': '4G', 'count': ['972']}, {'@valueName': '4G+', 'count': ['10']}, {'@valueName': '5G', 'count': ['2']}, {'@valueName': 'Bluetooth', 'count': ['968']}, {'@valueName': 'DLNA', 'count': ['1']}, {'@valueName': 'GPRS', 'count': ['1']}, {'@valueName': 'GPS', 'count': ['8']}, {'@valueName': 'Lightning', 'count': ['968']}, {'@valueName': 'LTE', 'count': ['13']}, {'@valueName': 'NFC', 'count': ['967']}, {'@valueName': 'WAP', 'count': ['1']}, {'@valueName': 'Wi-Fi', 'count': ['967']}]}, {'@name': 'Contract', 'valueHistogram': [{'@valueName': 'Without Contract', 'count': ['159']}, {'@valueName': 'Not Specified', 'count': ['1003']}]}, {'@name': 'Processor', 'valueHistogram': [{'@valueName': 'Dual Core', 'count': ['2']}, {'@valueName': 'Hexa Core', 'count': ['970']}, {'@valueName': 'Quad+Quad Core', 'count': ['1']}, {'@valueName': 'Quad Core', 'count': ['1']}, {'@valueName': 'Not Specified', 'count': ['192']}]}, {'@name': 'Style', 'valueHistogram': [{'@valueName': 'Bar', 'count': ['990']}, {'@valueName': 'Not Specified', 'count': ['172']}]}, {'@name': 'Operating System', 'valueHistogram': [{'@valueName': 'iOS', 'count': ['1058']}, {'@valueName': 'Not Specified', 'count': ['104']}]}, {'@name': 'Network', 'valueHistogram': [{'@valueName': '1&1', 'count': ['936']}, {'@valueName': 'AT&T', 'count': ['27']}, {'@valueName': 'Cricket Wireless', 'count': ['1']}, {'@valueName': 'Google Fi', 'count': ['3']}, {'@valueName': 'Metro', 'count': ['3']}, {'@valueName': 'Mint Mobile', 'count': ['1']}, {'@valueName': 'SaskTel', 'count': ['1']}, {'@valueName': 'Spectrum', 'count': ['1']}, {'@valueName': 'Sprint', 'count': ['4']}, {'@valueName': 'T-Mobile', 'count': ['40']}, {'@valueName': 'TracFone', 'count': ['2']}, {'@valueName': 'U.S. Cellular', 'count': ['1']}, {'@valueName': 'Unlocked', 'count': ['1093']}, {'@valueName': 'Verizon', 'count': ['32']}, {'@valueName': 'White Mobile', 'count': ['4']}, {'@valueName': 'Xfinity', 'count': ['2']}]}, {'@name': 'Memory Card Type', 'valueHistogram': [{'@valueName': 'CompactFlash', 'count': ['2']}, {'@valueName': 'eMMC', 'count': ['3']}, {'@valueName': 'Memory PRO Duo', 'count': ['1']}, {'@valueName': 'Not Specified', 'count': ['1156']}]}, {'@name': 'Lock Status', 'valueHistogram': [{'@valueName': 'Factory Unlocked', 'count': ['182']}, {'@valueName': 'Network Locked', 'count': ['14']}, {'@valueName': 'Network Unlocked', 'count': ['99']}, {'@valueName': 'Not Specified', 'count': ['868']}]}, {'@name': 'Camera Resolution', 'valueHistogram': [{'@valueName': '12.0 - 15.9 MP', 'count': ['761']}, {'@valueName': 'Not Specified', 'count': ['187']}]}, {'@name': 'Model', 'valueHistogram': [{'@valueName': 'Apple iPhone 11', 'count': ['470']}, {'@valueName': 'Apple iPhone 11 Pro', 'count': ['262']}, {'@valueName': 'Apple iPhone 11 Pro Max', 'count': ['380']}, {'@valueName': 'Apple iPhone X', 'count': ['2']}, {'@valueName': 'Not Specified', 'count': ['56']}]}, {'@name': 'Brand', 'valueHistogram': [{'@valueName': 'Apple', 'count': ['1085']}, {'@valueName': 'Sprint', 'count': ['4']}, {'@valueName': 'T-Mobile', 'count': ['24']}, {'@valueName': 'Verizon', 'count': ['27']}, {'@valueName': 'Not Specified', 'count': ['11']}]}, {'@name': 'SIM Card Slot', 'valueHistogram': [{'@valueName': 'Dual SIM', 'count': ['33']}, {'@valueName': 'Single SIM', 'count': ['100']}, {'@valueName': 'Not Specified', 'count': ['1029']}]}, {'@name': 'Model Number', 'valueHistogram': [{'@valueName': 'A1901 (GSM)', 'count': ['2']}, {'@valueName': 'A2111 (CDMA + GSM)', 'count': ['430']}, {'@valueName': 'A2160 (CDMA + GSM)', 'count': ['247']}, {'@valueName': 'A2161 (CDMA + GSM)', 'count': ['331']}, {'@valueName': 'Not Specified', 'count': ['145']}]}, {'@name': 'Color', 'valueHistogram': [{'@valueName': 'Black', 'count': ['181']}, {'@valueName': 'Blue', 'count': ['1']}, {'@valueName': 'Gold', 'count': ['95']}, {'@valueName': 'Gray', 'count': ['236']}, {'@valueName': 'Green', 'count': ['274']}, {'@valueName': 'Pink', 'count': ['2']}, {'@valueName': 'Purple', 'count': ['77']}, {'@valueName': 'Red', 'count': ['86']}, {'@valueName': 'Silver', 'count': ['67']}, {'@valueName': 'White', 'count': ['90']}, {'@valueName': 'Yellow', 'count': ['19']}, {'@valueName': 'Not Specified', 'count': ['34']}]}, {'@name': 'Storage Capacity', 'valueHistogram': [{'@valueName': '64 GB', 'count': ['1104']}, {'@valueName': '64 MB', 'count': ['1']}, {'@valueName': 'Not Specified', 'count': ['57']}]}, {'@name': 'Country/Region of Manufacture', 'valueHistogram': [{'@valueName': 'Canada', 'count': ['1']}, {'@valueName': 'China', 'count': ['20']}, {'@valueName': 'Togo', 'count': ['1']}, {'@valueName': 'United States', 'count': ['12']}, {'@valueName': 'Unknown', 'count': ['6']}, {'@valueName': 'Not Specified', 'count': ['1122']}]}]}]}]
你做了很多:

for k, v in d.items():
    if k == x:
        ...
通过键访问字典中的值。相反,您应该直接访问这些值。您可以通过方括号执行此操作:
v=d[x]
。如果该键不在字典中,这将引发错误,但如果该键不在字典中,则可以使用类似
d.get(x,[])
的方法返回默认值

results = call_api(keywords)
for key_info, value_info in results.items():
    print("Key_Info: ", key_info)
    for info in value_info:
        for results in info['searchResult']:
            for item in results['item']:
                print("Title: ", item['title'])

你做了很多:

for k, v in d.items():
    if k == x:
        ...
通过键访问字典中的值。相反,您应该直接访问这些值。您可以通过方括号执行此操作:
v=d[x]
。如果该键不在字典中,这将引发错误,但如果该键不在字典中,则可以使用类似
d.get(x,[])
的方法返回默认值

results = call_api(keywords)
for key_info, value_info in results.items():
    print("Key_Info: ", key_info)
    for info in value_info:
        for results in info['searchResult']:
            for item in results['item']:
                print("Title: ", item['title'])


谢谢你的建议。你认为哪一个是最有效的(最少的内存和步骤),为什么?它们非常相似。第一个稍微快一点,如果您处理的数据可能没有正确的键,第二个会更好谢谢这些提示。你认为哪一个是最有效的(最少的内存和步骤),为什么?它们非常相似。第一个稍微快一点,如果您处理的数据可能没有正确的键,第二个会更好