I am trying to convert a string (utf-8) using French date format to datetime using strptime:
import datetime as dt
from __future__ import unicode_literals
a = "Février 2017".encode('utf-8')
dt.datetime.strptime(a,"%B %Y")
Result:
ValueError: time data 'F\xc3\xa9vrier 2017' does not match format '%B %Y'
Problem is, strptime doesn't seem to handle unicode very well:
import datetime as dt
from __future__ import unicode_literals
a = "Février 2017"
dt.datetime.strptime(a,"%B %Y")
Result:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1: ordinal not in range(128)
Is there either an accepted format or an alternative to strptime?