“Python Get Data Plik Ostatni zmodyfikowany” Kod odpowiedzi

Python Windows Uzyskaj datę zmodyfikowaną plikiem

# note: test.txt can also be a file path
import os.path, time
print("Last modified: %s" % time.ctime(os.path.getmtime("test.txt")))
print("Created: %s" % time.ctime(os.path.getctime("test.txt")))
Stupid Shrew

Python Get Data Plik Ostatni zmodyfikowany

import os, time
# Get file's Last modification time stamp only in terms of seconds since epoch 
modTimesinceEpoc = os.path.getmtime(filePath)
# Convert seconds since epoch to readable timestamp
modificationTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(modTimesinceEpoc))
print("Last Modified Time : ", modificationTime )
Cheerful Chipmunk

Python otrzyma tworzenie daty pliku

import os
import platform

def creation_date(path_to_file):
    """
    Try to get the date that a file was created, falling back to when it was
    last modified if that isn't possible.
    See http://stackoverflow.com/a/39501288/1709587 for explanation.
    """
    if platform.system() == 'Windows':
        return os.path.getctime(path_to_file)
    else:
        stat = os.stat(path_to_file)
        try:
            return stat.st_birthtime
        except AttributeError:
            # We're probably on Linux. No easy way to get creation dates here,
            # so we'll settle for when its content was last modified.
            return stat.st_mtime
Cruel Cardinal

Python Otrzymuj czas modyfikacji pliku

import os
time = os.path.getmtime("file.txt")

print(time) # 1600113737.82
VeteranKilo

Odpowiedzi podobne do “Python Get Data Plik Ostatni zmodyfikowany”

Pytania podobne do “Python Get Data Plik Ostatni zmodyfikowany”

Więcej pokrewnych odpowiedzi na “Python Get Data Plik Ostatni zmodyfikowany” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu