我正在尝试在 python 中解析日期。我的代码适用于除 9 月以外的所有其他月份
这是我的代码
time.strptime("Sept. 30, 2014", "%b. %d, %Y")
我收到这个错误
ValueError: time data 'Sept. 30, 2014' does not match format '%b. %d, %Y'
最佳答案
九月的缩写是Sep,不是Sept。
>>> datetime.strptime("Sep. 30, 2014", "%b. %d, %Y")
datetime.datetime(2014, 9, 30, 0, 0)
Here's the list of all abbreviated month names for the en_US local.
关于python - 为什么 time.strptime ("Sept. 30, 2014", "%b. %d, %Y") 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31991435/