python爬虫时,将时间戳转换成正常的

import time

timestamp = items.get('created')
time_local = time.localtime(int(timestamp))

pub_date = time.strftime("%Y-%m-%d", time_local)
pub_time = time.strftime("%H:%M:%S", time_local)

可以得到日期:pub_time = 2018-01-20     pub_time = 12:05:22

猜你喜欢

转载自blog.csdn.net/xiongzaiabc/article/details/81182812