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()
下一篇: 树 - 树的同构