Skip to main content
 Web开发网 » 编程语言 » Python语言

Python中如何转换新浪微博返回的时间格式?

2021年11月27日5520百度已收录

import time

a = "Tue Apr 22 21:05:23 0800 2014"

b = a.repacle(" 0800 ","")#去掉时区

c = time.strptime(b,"%Y-%m-%d %H:%M:%S")#转换为时间元组

d = time.strftime("%Y-%m-%d %H:%M:%S",c) #转换成需求格式

结果

d = '2014-04-22 21:05:23'

评论列表暂无评论
发表评论
微信