如何解决在 %H:%M:%S:%f 中转换时间为 83 天,17:02:10.401369 python
我需要将 '83 days,17:02:10.401369' 的时间格式转换为 %H:%M:%S:%f
res_time = '83 days,17:02:10.401369'
res_formated = datetime.strptime(res_time,"%H:%M:%S.%f")
值错误:时间数据“83 天,17:02:10.401369”与格式“%H:%M:%S.%f”不匹配
解决方法
像@Klaus D. 说,使用 split 来使用字符串:
res_time = '83 days,17:02:10.401369'
res_time = res_time.split(",")[1]
res_time = res_time.strip() // Delete the white space before and after the string
res_formated = datetime.strptime(res_time,"%H:%M:%S.%f")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。