이 당신에게 도움이 될 수있는 기능입니다 :
from datetime import datetime
from os import path
from glob import glob
from time import time as current_time
def get_files(pattern, start=0, end=None):
"""
returns a list of all files in pattern where the files creation date is between start and end
pattern = the pattern to retrieve files using glob
start = the start date in seconds since the epoch (default: 0)
end = the end date in seconds since the epoch (default: now)
"""
start = datetime.fromtimestamp(start)
end = datetime.fromtimestamp(current_time() if end is None else end)
result = []
for file_path in glob(pattern):
if start <= datetime.fromtimestamp(path.getctime(file_path)) <= end:
result.append(file_path)
return result
예 : 스택 오버플로
>>> get_files('C:/Python27/*')
['C:/Python27\\DLLs', 'C:/Python27\\Doc', 'C:/Python27\\include', 'C:/Python27\\Lib', 'C:/Python27\\libs', 'C:/Python27\\LICENSE.txt', 'C:/Python27\\NEWS.txt', 'C:/Python27\\python.exe', 'C:/Python27\\pythonw.exe', 'C:/Python27\\README.txt', 'C:/Python27\\tcl', 'C:/Python27\\Tools']
에 오신 것을 환영합니다! 우리가 당신을 위해 몇 가지 코드를 작성하기를 원하는 것처럼 보입니다. 대부분의 사용자는 곤경에 처한 코더 코드를 기꺼이 만들지 만 일반적으로 포스터가 이미 문제를 해결하려고 시도했을 때만 도움이됩니다. 이러한 노력을 입증하는 좋은 방법은 지금까지 작성한 코드, 예제 입력 (있는 경우), 예상 출력 및 실제로 얻은 출력 (콘솔 출력, 스택 추적, 컴파일러 오류 등)을 포함시키는 것입니다. 응용할 수 있는). 더 자세하게 제공할수록 더 많은 답변을받을 수 있습니다. –