Changing Locale for datetime.strptime conversions

AlienBaby matt.j.warren at gmail.com
Tue Jul 6 06:03:34 EDT 2010


On 6 July, 10:55, AlienBaby <matt.j.war... at gmail.com> wrote:
> Hi,
>
> I'm using datetime.strptime(string,format) to convert dates parsed
> from a file into datetime objects.
>
> However, the files come from various places around the world, and
> strptime fails when non-english month names are used.
>
> strptime says it converts month names using the current locales
> version of the name.  I've looked into the locale module but can't see
> how I would setup.change a locales date/time representations, I can
> only see categories related to decimal number / currency
> representations.
>
> Can anyone show how I could change the locale such that strptime could
> parse a date string that used say, German month names?
>
> Thankyou

I just solved this I believe. I didnt spot LC_ALL or LC_TIME
previously.



More information about the Python-list mailing list