如何修复打开/读取json文件?

时间:2019-07-02 18:24:00

标签: python json python-3.x

我正在用python读取json文件,其中包含大量导入的商品数据:

import json

with open("data.json") as f:
data = json.load(f)

print(data)

但它显示此错误

File "C:\Users\ALAA\Desktop\hello\dictionary.py", line 4
    data = json.load(f)
       ^
IndentationError: expected an indented block

现在我收到此错误!!!

Traceback (most recent call last):
  File "C:\Users\ALAA\Desktop\hello\dictionary.py", line 2, in <module>
    with open("data.json") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'data.json'

1 个答案:

答案 0 :(得分:2)

您的代码缩进得不好

尝试一下:

java.lang.RuntimeException: json can't serialize type : class org.springframework.data.domain.example