python3 dict 写入json

python3 dict 写入json

from collections import defaultdict, OrderedDict
import json

test_dict = {
    'version': "1.0",
    'results': video,
    'explain': {
        'used': True,
        'details': "this is for josn test",
  }
}

json_str = json.dumps(test_dict, indent=4)
with open('test_data.json', 'w') as json_file:
    json_file.write(json_str)


posted @ 2022-04-26 20:43  michaelchengjl  阅读(288)  评论(0编辑  收藏  举报