如何更改 CSV 文件中的日期和时间格式(dd-mm-yyyy 和 dd-mm-yyyy) hh:mm:ss 转 mm/dd/yyyy 和hh:mm 使用 Python 吗?
我要去约会&来自 API 的时间结果,格式为 dd-mm-yyyy & hh-mm-ss。我想在 Python 中将其转换为 mm-dd-yyyy 格式,最简单/最快的方法是什么?
我尝试过使用 strftime。然而,我无法得到它。
I'm getting a date & time result from an API in the format dd-mm-yyyy & hh-mm-ss. I want to convert this to an mm-dd-yyyy format in Python, what's the easiest/quickest way?
I have tried using strftime. However, I could not get it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将旧时间转换为日期时间对象,然后可以将其重新格式化为新格式。
You can convert your old times to datetime objects, which can then be reformatted into the new format.