使用 time.strptime() 在 Python 中使用 AM/PM 解析日期时间字符串时出错
Error while parsing a datetime string with AM/PM in Python with time.strptime()
在 Python (3.7) 中使用 AM/PM 解析时间字符串时出现 ValueError:
from time import strptime
strptime('19/06/2019 07:49:53 PM', '%d/%m/%Y %I:%M:%S %p')
ValueError: unconverted data remains: PM
为什么会出现此错误?使用 %I
和 %p
应该能够解析 AM/PM 字符串...
在 Python (3.7) 中使用 AM/PM 解析时间字符串时出现 ValueError:
from time import strptime
strptime('19/06/2019 07:49:53 PM', '%d/%m/%Y %I:%M:%S %p')
ValueError: unconverted data remains: PM
为什么会出现此错误?使用 %I
和 %p
应该能够解析 AM/PM 字符串...