gpt4 book ai didi

python - Striptime Python 部分匹配

转载 作者:太空宇宙 更新时间:2023-11-04 10:25:09 31 4
gpt4 key购买 nike

<分区>

我的日期 2014-02-23T18:42:26.000009 的格式如下。我想提取日期,所以我使用了以下代码:

from datetime import datetime
date_object = datetime.strptime('2014-02-23T18:42:26.000009', '%Y-%m-%d')

但是,我收到以下错误消息:

Traceback (most recent call last):
File "C:/Users/d774911/PycharmProjects/GlobalData/Test2.py", line 4, in <module>
date_object = datetime.strptime('2014-02-23T18:42:26.000009', '%Y-%m-%d')
File "C:\Python34\lib\_strptime.py", line 500, in _strptime_datetime
tt, fraction = _strptime(data_string, format)
File "C:\Python34\lib\_strptime.py", line 340, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: T18:42:26.000009

有什么想法吗?

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com