为了账号安全,请及时绑定邮箱和手机立即绑定

如何改进在 Python 中移动所有不包含特定日期的文件?

如何改进在 Python 中移动所有不包含特定日期的文件?

catspeake 2021-06-17 13:01:07
我想移动所有不以今天开始的文件,我的代码如下,我可以更快地改进它吗?today = datetime.datetime.today().strftime('%Y%m%d')all_files = os.listdir(image_current_path)for i, image_file in enumerate(all_files):    if not image_file.startswith(today):        image_file = os.path.join(image_current_folder, image_file) # added        shutil.move(image_file, image_old_path)
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 135 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信