¿Cómo obtengo la fecha/hora de modificación de un archivo en Python?[duplicar]

StackOverflow https://stackoverflow.com/questions/121025

  •  02-07-2019
  •  | 
  •  

Pregunta

Esta pregunta ya tiene respuesta aquí:

¿Cómo obtengo la fecha/hora de modificación de un archivo en Python?

¿Fue útil?

Solución

os.path.getmtime(filepath)

o

os.stat(filepath).st_mtime

Otros consejos

Formateado:

import time
print time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(fname)))
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top