TypeError:预期的str,字节或os.PathLike对象,

问题描述

with open((item[1],'wb'),encoding='utf-8') as imge1:
                
                rttd = imge1.write()
                print(rttd)

我正在尝试访问此文件,但我不知道该怎么做,我尝试在“ with open”行之外使用解码和编码来尝试摆脱元组,但随后出现unicode错误。下面是我在上面编写此代码时的错误

TypeError: expected str,bytes or os.PathLike object,not tuple in Python

解决方法

open((item[1],'wb'),encoding='utf-8')中,参数0和1在元组内部(例如,G。(1、2、3))。请改为使用open(item[1],'wb',encoding='utf-8')

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...