python - 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)
但在控制台中,我看到了合适的甲酸盐。
非常感谢所有答复。
解决方案
推荐阅读
- excel - 我如何才能自动选择与每个月对应的参数?
- python - 在不知道其名称的情况下获得第一个通过的 kwarg 的 Pythonic 方式?
- c# - GraphQL.NET 动态字段类型
- javascript - 如果 props 是有效的 JSON,请检查 PropTypes
- elasticsearch - 在术语聚合中附加进一步的聚合
- javascript - 渲染没有父路由器视图的嵌套路由器视图 - React.js
- docker - Docker Windows 超时
- powerbi - Powerbi 计算列参数值传递,没有表关系
- angular - 使用代理时未在响应 cookie 中传递参数(XSRF 令牌)
- macos - 为什么我在 macOS Catalina 中看不到我的 SSH 密钥?