类型:Python,创建时间:Jan. 1, 2012, 2:33 p.m.
标题无“转载”即原创文章,版权所有。转载请注明来源:http://hgoldfish.com/blogs/article/51/。
不说什么,看代码:
#从sqlite3模块抄过来的东西,用于datetime,date到字符串之间的相互转换 def adapt_date(val): return val.isoformat() def adapt_datetime(val): return val.isoformat(" ") def convert_date(val): return datetime.date(*map(int, val.split("-"))) def convert_timestamp(val): datepart, timepart = val.split(" ") year, month, day = map(int, datepart.split("-")) timepart_full = timepart.split(".") hours, minutes, seconds = map(int, timepart_full[0].split(":")) if len(timepart_full) == 2: microseconds = int(timepart_full[1]) else: microseconds = 0 val = datetime.datetime(year, month, day, hours, \ minutes, seconds, microseconds) return val
标题无“转载”即原创文章,版权所有。转载请注明来源:http://hgoldfish.com/blogs/article/51/。
暂时还没有任何评论。