python 遍历嵌套字典
def list_all_dict(dict_a): if isinstance(dict_a,dict) : #使用isinstance检测数据类型 for x in range(len(dict_a)): temp_key = list(dict_a.keys())[x] temp_value = dict_a[temp_key] print("%s : %s" %(temp_key,temp_value)) temp_value={'cardData': {'area': '', 'attributes': '', 'attributesMap': {}, 'auctionType': 'b', 'benefitTags': [], 'brandId': '46476', 'brandName': 'Longines/浪琴', 'categoryId': '121454006', 'city': '泉州', 'collectNum': '0', 'collected': 'false', 'commentNum': '0', 'commonDO': {'redirectUrl': 'https://market.m.taobao.com/app/idleFish-F2e/fish-yp-v2/goodsdetail.html?itemId=653917235312'}, 'description': 'desc/icoss3282489002c21d84babd34b0ff', 'distance': '0.0', 'followed': 'false', 'hasUmpDiscount': '0', 'id': '653917235312', 'idleCoinBidItem': 'false', 'idleCoinBuynowItem': 'false', 'idleCoinItem': 'false', 'idleItemPriceDO': {'originalPrice': '619900', 'originalPriceText': '6199', 'price': '619900', 'priceText': '6199'}, 'idleItemStuffDO': {'stuffText': '95新'}, 'imageInfos': [{'major': 'true', 'url': 'http://img.alicdn.com/bao/uploaded/i4/348893495/O1CN01e3xpzU1bgkyBWX3lD_!!0-item_pic.jpg'}], 'inspectedItem': 'false', 'itemSource': '', 'itemStatus': '0', 'jymTradeItem': 'false', 'machCardType': 'MACH_FEEDS_YOUPIN_CARD', 'originalPrice': '6199', 'postFee': '0.00', 'price': '6199', 'province': '福建', 'resell': 'false', 'saleTags': [], 'serverTime': '2022-02-25 22:41:24', 'stuffStatus': '0', 'superFavorNum': '0', 'superFavored': 'false', 'title': '【98新】浪琴优雅系列表径35.60毫米精钢自动机械男表 公价10900', 'trackParam': {'rewriteq': '{}', 'original_price': '', 'item_id': '653917235312', 'city': '', 'channelcatid_v2': '', 'index': '18', 'channelcatid_v1': '', 'channelcatid_v4': '', 'channelcatid_v3': '', 'type': '1', 'title': '', 'search_id': '413097063da6009e33e6ee76bd7c5732', 'itemId': '653917235312', 'dataSourceId': '3146', 'pvid': 'f5cf23cd-88e6-4731-9918-02c62fcdba0a', 'id': '653917235312', 'position': '18', 'rn': '28c32615f3ece4499c80d3a3533434b7', 'scm': '1007.33969.210366.unirec000023969', 'category': '201157911', 'reserve_price': '', 'seller_id': ''}, 'trackParams': 'rewriteq:{};item_id:653917235312;index:18;id:653917235312;position:18;rn:28c32615f3ece4499c80d3a3533434b7;type:1;search_id:413097063da6009e33e6ee76bd7c5732;', 'userId': '348893495', 'userNick': '品***馆', 'videoid': '0', 'whiteBgPicUrl': 'https://gw.alicdn.com/bao/uploaded/i1/348893495/O1CN0168OtIk1bgkwvXZils_!!348893495.jpg', 'zhimaLevel': '0', 'zhimaScore': '0'}, 'machCardType': '1001', 'trackParam': {'rewriteq': '{}', 'original_price': '', 'item_id': '653917235312', 'city': '', 'channelcatid_v2': '', 'index': '18', 'channelcatid_v1': '', 'channelcatid_v4': '', 'channelcatid_v3': '', 'type': '1', 'title': '', 'search_id': '413097063da6009e33e6ee76bd7c5732', 'itemId': '653917235312', 'dataSourceId': '3146', 'pvid': 'f5cf23cd-88e6-4731-9918-02c62fcdba0a', 'id': '653917235312', 'position': '18', 'rn': '28c32615f3ece4499c80d3a3533434b7', 'scm': '1007.33969.210366.unirec000023969', 'category': '201157911', 'reserve_price': '', 'seller_id': ''}} list_all_dict(temp_value) #自我调用实现无限遍历