我有一个文件列表(实际上这些是某个目录中的文件),例如
import os
path = '/home/user/folder'
files = os.listdir(path)
所以结果如下
files = ['backup_file_2010-06-30_category.zip','backup_file_2010-06-28_category.zip',
'backup_file_2010-06-26_category.zip','backup_file_2010-06-24_category.zip',
'backup_file_2010-06-23_category.zip','backup_file_2010-06-20_category.zip'
'some_text_files_one.txt','some_text_files_two.txt']
所以从这个列表中我需要删除包含日期的zip文件,条件是, the files that are created before five days from today needs to be deleted
我的意思是如果今天创建的文件是backup_file_2013-04-17_category.zip
,我们需要删除从今天起五天之前创建的文件,例如名为的文件backup_file_2013-04-11_category.zip
谁能告诉我如何在python中做到这一点