2 回答

TA贡献1946条经验 获得超4个赞
import pytz
for line in jobs_info:
#print(line)
for i in range(len(line)):
if line[i] == None:
pass
else:
#print(datetime.strptime(line[4],'%Y-%m-%d %H:%M:%S'))
print(type(line[4]),type(line[5]))
try:
line[4] = datetime.strptime(line[4],'%Y-%m-%d %H:%M:%S')
line[4] = pytz.utc.localize(line[4])
line[4] = line[4].strftime('%Y-%m-%d %H:%M:%S')
line[5] = datetime.strptime(line[5],'%Y-%m-%d %H:%M:%S')
line[5] = pytz.utc.localize(line[5])
line[5] = line[5].strftime('%Y-%m-%d %H:%M:%S')
except:
pass
line = "|".join(line)
print (line)
结果:
BBBBB|20190213|成功|工作名称1|2019-02-14 18:11:55|2019-02-14 18:11:56|0.02 AAAAA|20190213|成功|工作名称2|2019-02-14|2019-02-14 2019-02-14 18:11:50|0.03 AAAA|20190213|WAITING|job_name4|None|None|0
添加回答
举报