python创建文件并写入json

python创建文件并写入json,第1张

python创建文件并写入json
import json
import os
import uuid

PATH = 'D:/SecurityData'
if not os.path.exists(PATH):
    os.makedirs(PATH)

fw = open('{}/Security.json'.format(PATH), 'a+')
fr = open('{}/Security.json'.format(PATH), 'r')
fw.write(json.dumps({
    'name': 'user_name',
    'uuid': str(uuid.uuid1())
}, ensure_ascii=False) + '\n')
fw.flush()

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/717501.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-25
下一篇 2022-04-25

发表评论

登录后才能评论

评论列表(0条)

保存