Python 读取json文件例子

语言:
Python
12 浏览
0 收藏
2小时前

代码实现

Python
import json

# Open and read the JSON file
with open('data.json', 'r') as file:
    data = json.load(file)

# Print the parsed data
print(data)

使用python读取json文件最简单的代码片段,使用内置的 json 模块实现JSON 文件的读取。

#json

片段说明

还可使用json.dumps()进行缩进控制

评论

加载中...