Odoo12:strptime 无法识别格式 %p (PM/AM)?

Odoo12 : strptime can't recognize format %p (PM/AM)?

我在模型函数中得到了这段代码:

data_ordine = order_dict['date'].replace(" UTC","").rstrip()        
_logger.info('Simone --> DATA ORDINE : %s',data_ordine + "|")        
if data_ordine: 
 data_finale = datetime.strptime(data_ordine,"%m/%d/%Y %I:%M%p")

当我尝试执行它时收到此错误:

File "/usr/lib/python3.5/_strptime.py", line 346, in _strptime    data_string[found.end():])ValueError: unconverted data remains: PM

在日志中,我保存了传递给 strptime 函数的数据,我可以看到它是:

2020-01-21 11:12:36,221 24082 INFO db_test odoo.addons.tepp_ept.models.sale_order: Simone --> DATA ORDINE : 01/12/2020 10:42PM|

我已经在 Python online compiler 上试过代码,似乎没问题:

from datetime import datetime 
str_date ="01/12/2020 10:42PM" 
date = datetime.strptime(str_date,"%m/%d/%Y %I:%M%p") 
print(date)

我哪里错了?

对于可能处于相同情况的那些,如@Adan-Cortez所示,它与区域设置有关(特别是LC_TIME设置)。 我通过临时重置它然后在 strptime 之后分配运算符值来解决它:

locale.setlocale(locale.LC_TIME, 'en_US.utf8')
if data_ordine:
   data_finale = datetime.strptime(data_ordine,"%m/%d/%Y %I:%M%p")

locale.setlocale(locale.LC_TIME, self.env.context['lang'] + '.utf8')