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

如何改进在 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 关注
  • 141 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号