0

this error is driving me crazy. This is an error that appears only on windows.

if platform == "linux" or platform == "linux2":
    locale.setlocale(locale.LC_TIME, "it_IT")
elif platform == "darwin":
    locale.setlocale(locale.LC_TIME, "it_IT")
elif platform == "win32":
    locale.setlocale(locale.LC_ALL, locale='Italian')

if I lunch:

print(locale.getlocale())
print(platform)

i get:

('Italian_Italy', '1252')
win32

the str I'm trying to parse is

zeta = '17 Apr 2020 09:00 PM'

with Datetime.strptime (from datetime import date time as dt)

beta = dt.strptime(zeta,("%d %b %Y %I:%M %p"))

  beta = dt.strptime(zeta,("%d %b %Y %I:%M %p"))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\_strptime.py", line 352, in _strptime
    raise ValueError("unconverted data remains: %s" %
ValueError: unconverted data remains: PM
  • May I ask, why are you using locale? – Thaer A Apr 17 '20 at 21:43
  • Because I’m trying to parse a string with the name of the month in Italian. I’m doing somenthing wrong ? – Anthony Tata Apr 17 '20 at 21:48
  • Can you share some of the date/time data you have in Italian? It doesn't seem that Italian Locale uses AM/PM in Windows See >>>print('Locale:', locale.getlocale()) >>>print('Time Representation:', time.strftime("%X") ) – Thaer A Apr 17 '20 at 22:21

0 Answers0