我有一些保存了日期的文件,例如foo161108part.txt
、baarr161108part2.txt
、python141106part2.txt
到目前为止,我列出了目录:
directoryFiles = []
for name in os.listdir(os.getcwd()):
if name.endswith('.txt'):
files.append(name)
print(files)
有很多不同日期的文件,我想看看有多少文件是在同一个日期出现的。你知道吗
谢谢!你知道吗
Tags:
为此,可以使用python的regex和Counter类:
输出:
如果目的只是比较文件的内容,那么理想的方法是使用^{} 模块。此模块提供^{} 方法,该方法:
示例:
如果日期部分是在文件名中搜索的关键部分,请考虑以下方法:
输出:
至于正则表达式:
相关问题 更多 >
编程相关推荐