首页 > 其他 > 详细

时间 字符串来回转换

时间:2017-08-08 00:14:05      阅读:279      评论:0      收藏:0      [点我收藏+]
import time, datetime

# 时间到字符串的转换
print time.strftime("%Y-%m-%d %X", time.localtime())
# 字符串到时间的转换
t = time.strptime("2008-08-08 09:32:10", "%Y-%m-%d %X")
print t[0:6]
y, m, d, H, M, S = t[0:6]
print datetime.datetime(y, m, d, H, M, S)

本文出自 “岳贺庚” 博客,请务必保留此出处http://yhgcenter.blog.51cto.com/2623981/1954276

时间 字符串来回转换

原文:http://yhgcenter.blog.51cto.com/2623981/1954276

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