将GMT格式的字符串转换为datetime格式

布瓦内什·桑卡兰(Bhuvanesh Sankaran)

转换时出现价值错误,

from datetime import datetime
b="Sep 23 09:53:38 2019 GMT"
date = datetime.strptime(b, "%d %b %Y")
print(date)
卡尔温

您必须完全分解时间字符串才能获得日期时间:

date = datetime.strptime(b, "%b %d %H:%M:%S %Y %Z")

datetime.datetime(2019、9、23、9、53、38)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将GMT格式的字符串转换为日期时间

将字符串转换为DateTime和格式

将字符串Date转换为DateTime格式?

将日期字符串转换为DateTime格式

将字符串从特定格式转换为 DateTIme

将字符串格式转换为

PHP 将 UTC 中的字符串日期时间转换为 GMT+7 格式

如何将 datetime.datetime 格式的字符串转换为 datetime 对象?

将字符串转换为 DateTime 格式而不将其转换为您的本地时间

如何将字符串转换为相同格式的datetime(datetime)?

使用pd.to_datetime将字符串日期转换为datetime格式时出错

如何将 DateTime 字符串格式转换为其他 DateTime?

将Unicode字符转换为字符串格式

将字符串列转换为DateTime格式

KDB:如何将DateTime转换为格式化的字符串?

Unity C#以所需的日期时间格式将日期字符串转换为datetime对象

将字符串转换为特定格式的DateTime对象(例如,不带日期)

如何使用非标准格式将字符串转换为 .Net DateTime 对象?

如何将JS日期字符串转换为Django datetime格式?

将DateTime转换为字符串格式yyyy-MM-dd时出错

如何将python datetime转换为具有可读格式date的字符串?

如何将Joda Time DateTime对象转换为SQL Server格式的字符串?

将字符串转换为有效的DateTime格式

如何将Calendar对象转换为ISO 8601格式的DateTime字符串?

将dd / mm / yyyy格式的字符串转换为Datetime

无法将格式yyyyMMddHHmmss的字符串日期转换为DateTime dart

将字符串格式的日期转换为datetime.date

将任何DateTime字符串格式转换为美国短日期“ MM-dd-yyyy”

将字符串日期格式'yymmdd'转换为datetime时出错