【问题标题】:error with time data does not match format时间数据错误与格式不匹配
【发布时间】:2018-08-08 19:24:43
【问题描述】:

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' 不匹配

【问题讨论】:

标签: python-3.x


【解决方案1】:

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

%y 匹配没有世纪的年份,但你有带世纪的年份,所以你需要大写 %Y

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    • 2021-03-31
    相关资源
    最近更新 更多