Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime, date, timedelta
- import calendar
- def calcular_rango_fechas(fecha_inicio=None):
- if fecha_inicio is None:
- fecha_inicio = date.today().replace(day=1)
- _, dias_mes = calendar.monthrange(fecha_inicio.year, fecha_inicio.month)
- fecha_final = fecha_inicio + timedelta(days=dias_mes)
- return (fecha_inicio, fecha_final)
- dia = timedelta(days=1)
- primer_dia, ultimo_dia = calcular_rango_fechas()
- while primer_dia < ultimo_dia:
- print(primer_dia)
- primer_dia += dia
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement