How do I strftime a date object in a different locale?
问题 I have a date object in python and I need to generate a time stamp in the C locale for a legacy system, using the %a (weekday) and %b (month) codes. However I do not wish to change the application\'s locale, since other parts need to respect the user\'s current locale. Is there a way to call strftime() with a certain locale? 回答1: The example given by Rob is great, but isn't threadsafe. Here's a version that works with threads: import locale import threading from datetime import datetime from