美文网首页
Python时间处理

Python时间处理

作者: uucloud | 来源:发表于2017-09-25 17:03 被阅读13次

http://www.cnblogs.com/shhnwangjian/p/6117602.html

今天遇到一个将

`Thu Sep 14 03:52:52 UTC 2017 `

这种格式的时间存入数据库的问题。根据以上cnblog可以写出如下方法

```

import datetime

ti = 'Thu Sep 14 03:52:52 UTC 2017'

datetime.datetime.strptime( ti, "%a %b %d %X UTC %Y")

```

不过读入是UTC,转换本地时间没找到现成的方法,可以自己减一下。

相关文章

网友评论

      本文标题:Python时间处理

      本文链接:https://www.haomeiwen.com/subject/czsdextx.html