编辑时间格式从类似的来源

时间:2016-02-03 20:19:46

标签: python python-3.x

尝试在" filetime"中编辑时间格式就像在"现在"。我尝试的一切都获取错误。我怎样才能获得" filetime"格式化为"现在"?

from time import gmtime, strftime, localtime
import time
import os

now = strftime ("%d %b %Y %H:%M:%S", localtime())
print (now)

filetime = time.ctime(os.path.getctime (r"C:\Users\harila\file.txt"))
print (filetime)

1 个答案:

答案 0 :(得分:-1)

ctime = os.path.getctime(r"C:\Users\harila\file.txt")
filetime = strftime("%d %b %Y %H:%M:%S", localtime(ctime))