python - 如何将文件创建/修改文件复制到新文件
问题描述
文件创建/修改时间有重要信息。在将文件转换为新文件(例如视频)时,如何在 Python 中保留创建/修改时间。就像是:
# pseudo code
old_time = original_video.gettime()
# new_video and original_video are totally different files.
new_video = create_and_convert(original_video)
# How to copy old file create/modify time to new file?
set_time(new_video, old_time)
我希望 new_video 具有完全相同的创建/修改时间。怎么做?
解决方案
为您的用例使用时间模块。
import time
old_time = time.ctime()
推荐阅读
- r - 如何从半同胞设计中计算遗传力
- django - 具有多个实例的 Django 应用程序 - 如何确保每日电子邮件只发送一次?
- python - 无法为 django settings.py 导入环境变量以在 linux ubuntu 系统中发送电子邮件
- graph-databases - anzograph - 无法连接到管理控制台
- c++ - 构造智能指向数据类型以及普通数据类型的通用方法
- typescript - 出现错误“TS2451:无法重新声明块范围变量‘全局’。” 使用打字稿和 webpack?
- java - AppiumDriverLocalService 自动下载chrome
- object - 实现 AT-POS 以返回对象而不是事物列表
- c++ - 如何将唯一指针的 std::vector 转换为原始指针的 std::span?
- c# - frame 不包含 SourcePageType 的定义