格林威治时间(GTM)转北京时间
需要模块:pytz(三方)和datetime
import pytz import datetime time = "Tue, 12 Jun 2012 14:03:10 GMT" gmt = pytz.timezone('GMT') eastern = pytz.timezone('Asia/Chongqing') date = datetime.datetime.strptime(time, '%a, %d %b %Y %H:%M:%S GMT') # 2012-06-12 14:03:10 print(date) dategmt = gmt.localize(date) # 2012-06-12 14:03:10+00:00 print(dategmt) dateeastern = dategmt.astimezone(eastern) # 2012-06-12 22:03:10+08:00 print(dateeastern)