How to convert `ctime` to `datetime` in Python?

前端 未结 4 648
失恋的感觉
失恋的感觉 2020-12-24 12:21
import time
t = time.ctime()

For me at the moment, t is \'Sat Apr 21 11:58:02 2012\'. I have more data like this.

4条回答
  •  萌比男神i
    2020-12-24 12:47

    Try datetime.strptime().

    See: http://docs.python.org/library/datetime.html#datetime.datetime.strptime

提交回复
热议问题