时间数据错误与格式不匹配

时间:2017-12-01 06:20:18

标签: python-3.x

I am having this data and try to convert the string date to datetime format. and I have this time data does not match format error.

    Date=stock['Trddt'].values
    datetime.datetime.strptime(Date[0], "%y.%m.%d")

并返回此错误: ValueError:时间数据' 2015/11/23'不符合格式'%y。%m。%d'

1 个答案:

答案 0 :(得分:0)

尝试datetime.datetime.strptime(Date[0], "%Y/%m/%d")

%y匹配没有世纪的年份,但是您拥有世纪的年份,因此需要资本%Y