首页 > 编程语言 > 详细

Python读写Json文件

时间:2015-08-06 20:25:06      阅读:200      评论:0      收藏:0      [点我收藏+]

 

一个小例子,使用Json配置文件

 

# -*- coding: utf-8 -*-
import json
import time



def store(data):
    with open(data.json, w) as json_file:
        json_file.write(json.dumps(data))

def load():
    with open(data.json) as json_file:
        data = json.load(json_file)
        return data



if __name__ == "__main__":

    data = {}
    data["last"]=time.strftime("%Y%m%d")
    store(data)

    data = load()
    print data["last"]

 

Python读写Json文件

原文:http://www.cnblogs.com/eejron/p/4708980.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!