代码
import timetime_stamp = int(time.time())loc_time = time.localtime(time_stamp)
time_1 = time.strftime("%Y-%m-%d %H:%M:%S",loc_time)print('utc时间戳:',time_stamp)
print('utc转本地时间:',time_1)
运行:
单行命令版——或许当前时间:
import time
print('当前时间:',time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(int(time.time()))))