Good afternoon! I need to solve the following scenario in python: I have one or more .txt files in a folder, but I want to return only the files that have the modification date according to the date I want (initial and final), but I'm not able to do this comparison as a date with user input:
import re
import os
from datetime import datetime as dt
#definindo datas
dtEntradaInicial = input('Data inicial: ')
dtEntradaFinal = input('Data final: ')
print(datetime.strptime(dtEntradaInicial, "%d/%m/%y").date())
print(datetime.strptime(dtEntradaFinal, "%d/%m/%y").date())
#testando retorno de data de modificação do arquivo
modificacao = datetime.fromtimestamp(os.path.getmtime('/c:/arquivoteste.txt'))
print('A data de modificação do arquivo é: ', modificacao)
if modificacao >= dtEntradaInicial and modificacao <= dtEntradaFinal:
print('Consegui comparar datas com sucesso!')