YouTip LogoYouTip

Os Utime

# Use os.stat to receive the file's access and modification times print "a2.py access time: %s" %stinfo.st_atime print "a2.py modification time: %s" %stinfo.st_mtime # Modify the access and modification times os.utime("a2.py",(1330712280, 1330712292)) print "done!!"

Executing the above program outputs the following result:

posix.stat_result(st_mode=33188, st_ino=3940649674337682L, st_dev=277923425L, st _nlink=1, st_uid=400, st_gid=401, st_size=335L, st_atime=1330498070, st_mtime=1330498074, st_ctime=1330498065)
a2.py access time: 1330498070
a2.py modification time: 1330498074
done!!

Python File Methods Python OS File/Directory Methods

← Os UtimeOs Ttyname β†’