In [1]: string_with_dates = """entries are due by January 4th, 2017 at 8:00pm created 01/15/2005 by ACME Inc. and associates."""
In [2]: import datefinder
In [3]: matches = datefinder.find_dates(string_with_dates)
In [4]: for match in matches:
...: print match
2017-01-04 20:00:00
2005-01-15 00:00:00
使用dateutil库。你知道吗
如果要检查日期的任何部分(月、年、日期)是否丢失,如果是,则避免。你知道吗
如果要从字符串(如“Reported 01 Jun 2018”)中提取日期,请使用
fuzzy=True
另一个解决方案。这是蛮力方法,检查每一个格式的日期。继续添加更多的格式,使它在任何日期格式的工作。但这是一种耗时的方法。你知道吗
希望这能帮助你从日期字符串中找到日期
相关问题 更多 >
编程相关推荐