标签: python
我想在python中将Wed, 14 Mar 2018 07:30:00 GMT转换为 2018/03/14 。我收到unicode object has no attribute strftime错误。有人帮助我。
Wed, 14 Mar 2018 07:30:00 GMT
unicode object has no attribute strftime
答案 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')
您可以阅读以下链接了解更多详情:
strptime的Python文档:Python 2,Python 3
strptime
strftime的Python文档:Python 2,Python 3
strftime