使用 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 字符串...

你的代码在我的笔记本上运行,看起来还有其他问题。

我发现 this and this 搜索您的错误,您使用的是 arcpy 还是 pynotify?或者任何其他可能导致冲突的库?

如果出现此类错误,请尝试删除一些导入以进行本地化