1 移动文件 复制文件 忽略错误
“Destination path ‘%s’ already exists” % real_dst
目标路径“%s”已存在“%real”
try :
shutil.move(文件, "长期不用文件/")
except KeyError :
continue
except OSError :
continu
2 命令和文件名重名
AttributeError: partially initialized module 'cv2' has no attribute 'imread' (most likely due to a circular import)
2、报错翻译过来的结果就是:AttributeError:部分初始化的模块“itchat”没有属性“auto_login”(很可能是由于循环导入)
我再看了看我的命名方式,我就笑了~~~,我的文件命名为 itchat.py 了 ,这就是给自己挖坑,改了文件名就好了,改成了test_itchat.py

3 路径醋味
‘NoneType’ object has no attribute ‘shape’

4 文件名错误
‘NoneType’ object has no attribute ‘shape’


本文探讨了Python编程中常见的错误,如移动或复制文件时遇到已存在目标路径的问题,以及模块和文件名冲突导致的AttributeError。还提到了路径处理和检查文件属性时可能出现的NoneType错误。解决问题的方法包括检查文件操作的异常处理,避免文件命名与库名冲突,以及正确处理文件路径和对象。
849





