novel-doomsday-resurgence/debug_index_json.py

28 lines
855 B
Python
Raw Normal View History

#!/usr/bin/env python3
import json
# 读取 index.json 文件
index_path = "books/末日重生-开局囤货十亿物资/chapters/index.json"
with open(index_path, 'r', encoding='utf-8') as f:
data = json.load(f)
print(f"数据长度: {len(data)}")
# 检查第86个元素索引85
if len(data) > 85:
item = data[85]
print(f"\n第86个元素索引85:")
print(json.dumps(item, ensure_ascii=False, indent=2))
# 检查 title 字段
if 'title' in item:
print(f"\ntitle 字段: '{item['title']}'")
print(f"title 长度: {len(item['title'])}")
print(f"title 类型: {type(item['title'])}")
else:
print("\n缺少 title 字段")
# 检查所有字段
print(f"\n所有字段: {list(item.keys())}")
else:
print(f"数据只有 {len(data)} 个元素没有第86个元素")