我正在尝试将时间(例如15小时)从东部时间转换为 乌拉圭所在的时区(东部时间+ 1小时)。然后我尝试转换显示 从15到15:00。
问题是,进行此转换时,我会额外获得11点 分钟,我无法解决原因。请帮忙吗?
我现在的代码:
eastern = pytz.timezone('US/Eastern')
uruguay = pytz.timezone('America/Montevideo')
print("Top 5 Hours for comments in Uruguay's time:")
for avg, hr in ordered_avg[0:5]:
time_1 = dt.datetime.strptime(str(hr), "%H")
time_2 = eastern.localize(time_1)
time_3 = time_2.astimezone(uruguay).strftime("%H:%M")
print('{}: {:.2f} average comments per post'.format(time_3, avg))
打印时循环第一行的结果:
time_1 = 1900-01-01 15:00:00
time_2 = 1900-01-01 15:00:00-04:56
time_3 = 16:11
16:11: 28.68 average comments per post
预期的结果(目前还不行):
time_3 = 16:00
16:00: 28.68 average comments per post