小编use*_*511的帖子

json.dump 未写入文件

我将dump这样的函数与名为 test.py 的文件一起使用:

import json

li = [2, 5]
test = open('test.json', 'w')
json.dump(li, test)
Run Code Online (Sandbox Code Playgroud)

但代码运行后并没有写入 JSON 文件。为什么是这样?正确的使用方法是什么json.dump

python file-io json python-3.x

2
推荐指数
1
解决办法
5797
查看次数

标签 统计

file-io ×1

json ×1

python ×1

python-3.x ×1