How can I remove a pytz timezone from a datetime object?
问题 Is there a simple way to remove the timezone from a pytz datetime object? e.g. reconstructing dt from dt_tz in this example: >>> import datetime >>> import pytz >>> dt = datetime.datetime.now() >>> dt datetime.datetime(2012, 6, 8, 9, 27, 32, 601000) >>> dt_tz = pytz.utc.localize(dt) >>> dt_tz datetime.datetime(2012, 6, 8, 9, 27, 32, 601000, tzinfo=<UTC>) 回答1: To remove a timezone (tzinfo) from a datetime object: # dt_tz is a datetime.datetime object dt = dt_tz.replace(tzinfo=None) If you are