Hi
ich möchte ein Programm schreiben mit dem ich alle dateien eines ordners anzeigen lassen kann die in den letzten 7tagen geändert worden sind aber ich finde kein befehl um das änderungsdatum auszulesen könnt ihr mir helfen?
MfG
web
Änderungsdatum einer Datei auslesen
- gerold
- Python-Forum Veteran
- Beiträge: 5555
- Registriert: Samstag 28. Februar 2004, 22:04
- Wohnort: Oberhofen im Inntal (Tirol)
- Kontaktdaten:
Hi web!web hat geschrieben:befehl um das änderungsdatum auszulesen
Willkommen im Python-Forum!
--> os.path.getmtime()
http://docs.python.org/lib/module-os.path.html
mfg
Gerold
http://halvar.at | Kleiner Bascom AVR Kurs
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
- gerold
- Python-Forum Veteran
- Beiträge: 5555
- Registriert: Samstag 28. Februar 2004, 22:04
- Wohnort: Oberhofen im Inntal (Tirol)
- Kontaktdaten:
Ohne Worte!web hat geschrieben:"is not defined"
Code: Alles auswählen
import os.path
print os.path.getmtime("<Pfad zur Datei>")
http://halvar.at | Kleiner Bascom AVR Kurs
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
- gerold
- Python-Forum Veteran
- Beiträge: 5555
- Registriert: Samstag 28. Februar 2004, 22:04
- Wohnort: Oberhofen im Inntal (Tirol)
- Kontaktdaten:
Hi web!web hat geschrieben:bin anfänger
Dann merke dir bitte folgendes gleich am Anfang: Lies die Dokumentation zu einem Befehl, bevor du hier eine Frage zu diesem Befehl stellst.
http://docs.python.org/lib/module-os.path.html
http://docs.python.org/lib/module-time.htmlgetmtime(path)
Return the time of last modification of path. The return value is a number giving the number of seconds since the epoch (see the time module). Raise os.error if the file does not exist or is inaccessible. New in version 1.5.2. Changed in version 2.3: If os.stat_float_times() returns True, the result is a floating point number.
ctime([secs])
Convert a time expressed in seconds since the epoch to a string representing local time. If secs is not provided or None, the current time as returned by time() is used. ctime(secs) is equivalent to asctime(localtime(secs)). Locale information is not used by ctime(). Changed in version 2.1: Allowed secs to be omitted. Changed in version 2.4: If secs is None, the current time is used.
gmtime([secs])
Convert a time expressed in seconds since the epoch to a struct_time in UTC in which the dst flag is always zero. If secs is not provided or None, the current time as returned by time() is used. Fractions of a second are ignored. See above for a description of the struct_time object. See calendar.timegm() for the inverse of this function. Changed in version 2.1: Allowed secs to be omitted. Changed in version 2.4: If secs is None, the current time is used.
mfglocaltime([secs])
Like gmtime() but converts to local time. If secs is not provided or None, the current time as returned by time() is used. The dst flag is set to 1 when DST applies to the given time. Changed in version 2.1: Allowed secs to be omitted. Changed in version 2.4: If secs is None, the current time is used.
Gerold
http://halvar.at | Kleiner Bascom AVR Kurs
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
- gerold
- Python-Forum Veteran
- Beiträge: 5555
- Registriert: Samstag 28. Februar 2004, 22:04
- Wohnort: Oberhofen im Inntal (Tirol)
- Kontaktdaten:
Code: Alles auswählen
>>> import os.path
>>> import time
>>> os.path.getmtime(r"C:\BcBtRmv.log")
1155809163
>>> time.ctime(os.path.getmtime(r"C:\BcBtRmv.log"))
'Thu Aug 17 12:06:03 2006'
>>> time.gmtime(os.path.getmtime(r"C:\BcBtRmv.log"))
(2006, 8, 17, 10, 6, 3, 3, 229, 0)
>>> time.localtime(os.path.getmtime(r"C:\BcBtRmv.log"))
(2006, 8, 17, 12, 6, 3, 3, 229, 1)
>>>
Gerold
http://halvar.at | Kleiner Bascom AVR Kurs
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.