# coding:UTF-8 import time def timestamp_to_dt(timestamp, format_type="%Y-%m-%d %H:%M:%S"): # 转换成localtime time_local = time.localtime(timestamp) # 转换成新的时间格式(2016-05-05 20:28:54) dt = time.strftime(format_type, time_local) return dt