import json import pandas as pd with open('data2.json', 'r') as f: data = json.load(f) try: goods = [] items = data['items'] for item in items: goods_model = item['item_data']['goods_model'] goods_id = str(goods_model['goods_id']) goods_name = goods_model['goods_name'] link_url = goods_model['link_url'] if "卡奇尔" in goods_name: good = { "goods_id": goods_id, "goods_name": goods_name, "link_url": link_url } # 将 JSON 对象添加到 JSON 数组中 goods.append(good) except (KeyError, TypeError) as e: print(f"Error parse value : {e}") list = None df = pd.DataFrame(goods) # 将 DataFrame 写入 Excel 文件 df.to_excel('output.xlsx', index=False, engine='xlsxwriter')