def get_goods_list(goods_resp, _format): goods_list = [] if _format == 'json': for goods_cate in goods_resp: goods_list = goods_list + goods_cate['goods'] if _format == 'xml': for goods_cate in goods_resp['cate']: if isinstance(goods_cate['goods']['item'], dict): goods_list.append(goods_cate['goods']['item']) else: goods_list = goods_list + goods_cate['goods']['item'] return goods_list