def json_to_text(json_file_path):
# 读取JSON文件
with open(json_file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
# 调试输出JSON数据结构
print("JSON数据结构:", data)
# 将JSON数据转换为文本格式
text = ""
for item in data:
print("当前条目:", item)
for key, value in item.items():
text += f"{key}: {value}\n"
text += "\n" # 添加空行分隔不同的条目
return text
/data/user/0/org.qpython.qpy/files/bin/qpy thon3.sh "/storage/emulated/0/qpython/json 处理2.py" && exit
python/json处理2.py" && exit < Traceback (most recent call last):
File "/storage/emulated/0/qpython/json处 理2.py", line 22, in <module>
text_data = json_to_text(json_file_pat h)
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^
File "/storage/emulated/0/qpython/json处 理2.py", line 12, in json_to_text
for key, value in item.items():
^^^^^^^^^^
AttributeError: 'str' object has no attrib ute 'items'
1|:/ $