时间戳批量修改为时间

"""
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)
        # return otherStyleTime
        print(otherStyleTime)
    else:
        print('请输入11位以内的数字')


time_list = []
for lines in open('时间', encoding='utf8'):
    lines = lines.strip()
    lines = time_turn(lines)
    time_list.append(lines)

  

posted @ 2021-10-20 16:21  布都御魂  阅读(186)  评论(0编辑  收藏  举报