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

2024-04-25 05:17:38 发布

您现在位置:Python中文网/ 问答频道 /正文

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

import json

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

print(data)

但它显示了这个错误

^{pr2}$

现在我得到了这个错误!!!在

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'

Tags: 文件数据importjsonmostdataas错误