【发布时间】:2011-10-11 15:38:17
【问题描述】:
我需要使用 python 从文件名中提取日期。日期格式如下:
month-day-year.somefileextension
例子:
10-12-2011.zip
somedatabase-10-04-2011.sql.tar.gz
最好的提取方法是使用正则表达式?
我有一些代码:
import re
m = re.search('(?<=-)\w+', 'derer-10-12-2001.zip')
print m.group(0)
代码将打印“10”。关于如何打印日期的一些线索?
最好的问候,
【问题讨论】: