首页 > 解决方案 > CSV在用csv python编写时更改日期和时间格式?

问题描述

基本上我有以下格式的日期/时间,2018-9-10 16:5:21但是当我将它写入 csv 文件时,它会将日期/时间格式转换为10/09/2018 4:05:21 PM

脚本:

now = datetime.datetime.now()
timetoout = str(now.year)+"-"+str(now.month)+"-"+str(now.day)+" "+str(now.hour)+":"+str(now.minute)+":"+str(now.second)
spamwriter.writerow([x] + [x+", "+x] + [x] + [x] + [x] + [timetoout] + [x] + [x])
print(timetoout)

但在控制台中,我看到了合适的甲酸盐。

非常感谢所有答复。

标签: pythondatetime

解决方案


推荐阅读