python操作json

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json

with open('C:/Users/jiangwenwen/Desktop/test.json', 'a', encoding='utf-8') as file:

    for i in range(100):

        data = {}

        data[i] = {"S" : "姜文文"}

        file.write(json.dumps(data, ensure_ascii = False))
        
        file.write("\n")

file.close()

posted @ 2019-11-12 22:11  姜文文  阅读(38)  评论(0编辑  收藏