>>> a='2015-6-9'
>>> datetimeObj = time.strptime(a, "%Y-%m-%d")
>>> datetimeObj
(2015, 6, 9, 0, 0, 0, 1, 160, -1)
>>> time.strftime("%Y%m%d",datetimeObj)
'20150609'
python 时间字符串格式转换
最新推荐文章于 2024-09-04 10:31:20 发布
>>> a='2015-6-9'
>>> datetimeObj = time.strptime(a, "%Y-%m-%d")
>>> datetimeObj
(2015, 6, 9, 0, 0, 0, 1, 160, -1)
>>> time.strftime("%Y%m%d",datetimeObj)
'20150609'