从字符串中提取DateTime对象(lexPredict fork)
datefinder-lexpredict的Python项目详细描述
用于在文本中定位日期的python模块。使用此包提取所有类型 将文档中类似日期的字符串转换为日期时间对象。
此模块查找可能的日期时间字符串,然后使用 dateparser要转换的包 到DateTime对象。
安装
pip install datefinder
如何使用
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]:importdatefinderIn[3]:matches=datefinder.find_dates(string_with_dates)In[4]:formatchinmatches:...:printmatch...:2017-01-0420:00:002005-01-1500:00:00