如何将文件创建/修改文件复制到新文件



文件创建/修改时间包含重要信息。将文件转换为新文件(例如视频(时,如何在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()

最新更新