欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Python3 - 时间戳转日期

程序员文章站 2022-03-24 15:58:21
...
import pymongo
import time
from bson.int64 import long

# 输入 - 文件
inPath = 'D:/projectData/EcSystem/Amazon/ratings.csv'
inFile = open(inPath, 'r', encoding='UTF-8')

for line in inFile:
    # 去掉末尾换行符
    line = line.strip('\n')
    arr = line.split(',')
    try:
        time01 = time.localtime(long(arr[3]))
        time02 = time.strftime("%Y-%m-%d", time01)
        print(time02)
    except:
        print(line)

inFile.close()
相关标签: Python3 Python3