python獲得文件創建時間和修改時間的方法
來源:懂視網
責編:小采
時間:2020-11-27 14:41:01
python獲得文件創建時間和修改時間的方法
python獲得文件創建時間和修改時間的方法:本文實例講述了python獲得文件創建時間和修改時間的方法。分享給大家供大家參考。具體如下: 這里需要用戶從控制臺輸入文件路徑 import os.path, time import exceptions class TypeError (Exception): pass if __name__ =
導讀python獲得文件創建時間和修改時間的方法:本文實例講述了python獲得文件創建時間和修改時間的方法。分享給大家供大家參考。具體如下: 這里需要用戶從控制臺輸入文件路徑 import os.path, time import exceptions class TypeError (Exception): pass if __name__ =

本文實例講述了python獲得文件創建時間和修改時間的方法。分享給大家供大家參考。具體如下:
這里需要用戶從控制臺輸入文件路徑
import os.path, time
import exceptions
class TypeError (Exception):
pass
if __name__ == '__main__':
if (len(os.sys.argv) < 1):
raise TypeError()
else:
print "os.sys.argv[0]: %s" % os.sys.argv[0]
# os.sys.argv[0] is the current file, in this case, file_ctime.py
f = os.sys.argv[0]
mtime = time.ctime(os.path.getmtime(f))
ctime = time.ctime(os.path.getctime(f))
print "Last modified : %s, last created time: %s" % (mtime, ctime)
希望本文所述對大家的Python程序設計有所幫助。
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
python獲得文件創建時間和修改時間的方法
python獲得文件創建時間和修改時間的方法:本文實例講述了python獲得文件創建時間和修改時間的方法。分享給大家供大家參考。具體如下: 這里需要用戶從控制臺輸入文件路徑 import os.path, time import exceptions class TypeError (Exception): pass if __name__ =