使用python将GMT转换为stftime

时间:2018-03-14 09:16:34

标签: python

我想在python中将Wed, 14 Mar 2018 07:30:00 GMT转换为 2018/03/14 。我收到unicode object has no attribute strftime错误。有人帮助我。

1 个答案:

答案 0 :(得分:0)

使用:

from datetime import datetime
date_given = 'Wed, 14 Mar 2018 07:30:00 GMT'
datetime.strptime(date_given, '%a, %d %b %Y %H:%M:%S %Z').strftime('%Y/%m/%d')

您可以阅读以下链接了解更多详情: