python时间戳转换UTC时间

from datetime import datetime as DT
import time

time_stamp = 1605151831
time_stame_array = time.localtime(time_stamp)
y = time.strftime("%Y-%m-%d %H:%M:%S",time_stame_array)
x = DT.utcfromtimestamp(time_stamp).strftime("%Y-%m-%d %H:%M:%S")
print('UTC时间:',x)
print('本地时间:',y)
原文地址:https://www.cnblogs.com/wztshine/p/13967796.html