在Python中为许多相同格式的日期猜测日期格式 [英] Guessing date format for many identically-formatted dates in Python

查看:178
本文介绍了在Python中为许多相同格式的日期猜测日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一大堆datetime字符串,可以安全地假设它们都是相同格式的。例如,我可能有一组日期7/1/13 0:45,5/2/13 6:21,7/15/13 1:24,7/9/13 12 :41,4/30/13 3:12。这个想法将是以合理的可靠性获得他们的共同格式,以便它们可以使用strptime或类似的解析。



有没有任何简单的方法来猜测格式?理想的是一个这样做的图书馆?

解决方案

查看 https://github.com/jeffreystarr/dateinfer



似乎有点放弃,但也许会符合你的需要。


I have a large set of datetime strings and it can be safely assumed that they're all identically formatted. For example, I might have the set of dates "7/1/13 0:45", "5/2/13 6:21", "7/15/13 1:24", "7/9/13 12:41", "4/30/13 3:12". The idea would be to get their common format with a reasonable amount of reliability so that they can be parsed using strptime or similar.

Is there any easy way to guess the format? Ideally a library that does this?

解决方案

Check out https://github.com/jeffreystarr/dateinfer

Seems a little abandoned but maybe it will go with your needs.

这篇关于在Python中为许多相同格式的日期猜测日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆