您现在的位置是:主页 > news > 电子商务网站建设商城网站/湖南seo推广多少钱

电子商务网站建设商城网站/湖南seo推广多少钱

admin2025/5/13 21:23:08news

简介电子商务网站建设商城网站,湖南seo推广多少钱,爱情表白制作网页的网站,城乡建设部注册建筑师网站我有一个脚本,需要做一些基于文档创建&修改日期,但必须在Linux上运行。视窗。什么是最好的 跨平台 的方式来获得文档创建&修改Python中的日期/时间?以跨平台方式获取修改日期非常简单 - 只需调用os.path.getmt…

电子商务网站建设商城网站,湖南seo推广多少钱,爱情表白制作网页的网站,城乡建设部注册建筑师网站我有一个脚本,需要做一些基于文档创建&修改日期,但必须在Linux上运行。视窗。什么是最好的 跨平台 的方式来获得文档创建&修改Python中的日期/时间?以跨平台方式获取修改日期非常简单 - 只需调用os.path.getmt…

我有一个脚本,需要做一些基于文档创建&修改日期,但必须在Linux上运行。视窗。

什么是最好的 跨平台 的方式来获得文档创建&修改Python中的日期/时间?

以跨平台方式获取修改日期非常简单 - 只需调用os.path.getmtime( _),你将得到path代码>最后修改。

另一方面,获取文档 创建 日期依赖于平台和平台,甚至在三个大操作系统之间也是不同的:

把这一切放在一起,跨平台的代码应该看起来像这样…import os

import platform

def creation_date(path_to_file):

"""

Try to get the date that a file was created, falling back to when it was

last modified if that isn't possible.

See http://stackoverflow.com/a/39501288/1709587 for explanation.

"""

if platform.system() == 'Windows':

return os.path.getctime(path_to_file)

else:

stat = os.stat(path_to_file)

try:

return stat.st_birthtime

except AttributeError:

# We're probably on Linux. No easy way to get creation dates here,

# so we'll settle for when its content was last modified.

return stat.st_mtimeimport os.path, time

print("last modified: %s" % time.ctime(os.path.getmtime(file)))

print("created: %s" % time.ctime(os.path.getctime(file)))

您的其他选项是使用os.stat:import os, time

(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(file)

print("last modified: %s" % time.ctime(mtime))

注意**:` __(感谢高二郎通过提供一个有趣的博客文章的链接,使这一事实更清晰)

未经作者同意,本文严禁转载,违者必究!