时间戳批量修改为时间

"""
author:张鑫
date:2021/7/30 20:39
"""
import time


def time_turn(timenum):
if 0 < len(timenum) < 11 and timenum.isdigit():
timenum = int(timenum)
timeArray = time.localtime(timenum)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
print(otherStyleTime)
else:
print('请输入11位以内的数字')

time_list = []
for lines in open('时间', encoding='utf8'):
lines = lines.strip()
lines = time_turn(lines)
time_list.append(lines)
上一篇:python文件


下一篇:实验三: 类和对象Ⅱ