【问题标题】:How do I get the modified date/time of a file in Python? [duplicate]如何在 Python 中获取文件的修改日期/时间? [复制]
【发布时间】:2010-09-12 08:53:55
【问题描述】:

如何在 Python 中获取文件的修改日期/时间?

【问题讨论】:

    标签: python file


    【解决方案1】:
    os.path.getmtime(filepath)
    

    os.stat(filepath).st_mtime
    

    【讨论】:

    【解决方案2】:

    格式化:

    import time
    print time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(fname)))
    

    【讨论】:

      猜你喜欢
      • 2015-02-19
      • 2010-09-27
      • 1970-01-01
      • 2017-12-16
      • 2010-09-19
      • 2011-11-29
      • 2016-03-21
      • 2012-05-16
      • 2014-06-08
      相关资源
      最近更新 更多