Http://zhidao.baidu.com/link?url=wNI9K20mR7-9necxd6zK1bWnBQ-EmuggOzS0JNVZ0G_ Mpsqn31ti6l3i0j0dyycanhuxoqls6axyv0cb0yx3cg9dncoiv5n4qegw7hafqxi
We get through the file attributes, the Os.stat () method:
>>> Import OS
>>> Statinfo=os.stat (r "C:/1.txt")
>>> Statinfo
(33206, 0L, 0, 0, 0, 0, 29L, 1201865413, 1201867904, 1201865413)
Use the return value of Os.stat statinfo three properties to get the file creation time, etc.
St_atime (Access Time), St_mtime (modified time), St_ctime (creation time), for example, get file modification time:
>>> Statinfo.st_mtime
1201865413.8952832
This time is a Linux timestamp and needs to be converted
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)
February 1, 2008 19:30 13 seconds (2008-2-1 19:30:13)
Python gets file timestamp