python 时间字符串格式转换

>>> 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)