摘要: python2.6+ 自带的json模块,不支持datetime的json encode,每次都需要手动转为字符串,很累人,我们可以自己封装一个简单的方法处理此问题.实现代码如下:import jsonfrom datetime import date, datetimedef __default(obj): if isinstance(obj, datetime): return obj.strftime('%Y-%m-%dT%H:%M:%S') elif isinstance(obj, date): return obj.strftime('%Y-%m-%d' 阅读全文
posted @ 2010-10-23 18:20 MK2 阅读(2757) 评论(0) 推荐(1) 编辑