test.py 374 B

12345678910111213141516
  1. import json
  2. import pandas as pd
  3. with open('data.json', 'r') as f:
  4. data = json.load(f)
  5. try:
  6. list = data['stores']['store']['data']['ssrListData']['list']
  7. except (KeyError, TypeError) as e:
  8. print(f"Error parse value : {e}")
  9. list = None
  10. df = pd.DataFrame(list)
  11. # 将 DataFrame 写入 Excel 文件
  12. df.to_excel('output.xlsx', index=False, engine='xlsxwriter')