Often, we need to get the attributes of a file, such as creation date, access date, modification date, size, read-only, or hidden property. It's quite handy to use Python. Here's how I get through the data:
The file attribute was obtained using the Os.stat () method:
>>> Import OS
>>> Statinfo = Os.stat (r "C:/1.txt")
>>> Statinfo
(33206, 0L, 0, 0, 0, 0, 29L, 1201865413, 1201867904, 1201865413)
Gets the creation time of the file using the Os.stat return value Statinfo three properties
St_atime (Access Time), St_mtime (modification time), St_ctime (creation time), for example, get file creation time:
>>> Statinfo.st_ctime
1201865413.8952832
Why is such a large floating-point number AH. What does this time mean.
Recent studies have learned that this is the "seconds" starting from 1970-1-1 08:00:00, which means that this time is from 1970-1-1 to 08:00:00, after 1,201,865,413,.89,528 seconds. So what time is this time?
Use the LocalTime function in the time module to know: >>> import time
>>> Time.localtime (Statinfo.st_ctime)
(2008, 2, 1, 19, 30, 13, 4, 32, 0)
See, February 1, 2008 19:30 13 seconds (2008-2-1 19:30:13), hehe
In addition, the Statinfo properties are:
St_size (file size, expressed in bytes)
These are tested on Windows XP. Please refer to the Python manual for the countless details.