Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
类型错误:';int';读取图像大小时对象不可编辑 代码 错误 (C:\Users\SACHIN\Anaconda2)D:\>python R6extractor.py 6220800 回溯(最近一次呼叫最后一次): 文件“R6extractor.py”,第14行,在 宽度、高度=img.size TypeError:“int”对象不可编辑_Python_Python 2.7 - Fatal编程技术网

类型错误:';int';读取图像大小时对象不可编辑 代码 错误 (C:\Users\SACHIN\Anaconda2)D:\>python R6extractor.py 6220800 回溯(最近一次呼叫最后一次): 文件“R6extractor.py”,第14行,在 宽度、高度=img.size TypeError:“int”对象不可编辑

类型错误:';int';读取图像大小时对象不可编辑 代码 错误 (C:\Users\SACHIN\Anaconda2)D:\>python R6extractor.py 6220800 回溯(最近一次呼叫最后一次): 文件“R6extractor.py”,第14行,在 宽度、高度=img.size TypeError:“int”对象不可编辑,python,python-2.7,Python,Python 2.7,但当我在谷歌上搜索如何获取图像的宽度和高度时,几乎每个例子都显示使用宽度,高度=image.size。我也这么做了。但我发现了这个错误,所以我检查了image.size的内容,得到了6220800。那么,我在这里做错了什么呢?正如@TheLoverter4865在评论中所说的那样,img.size返回一个整数,不能解包 您需要做的是: (C:\Users\SACHIN\Anaconda2) D:\>python R6extractor.py 6220800 Trace

但当我在谷歌上搜索如何获取图像的宽度和高度时,几乎每个例子都显示使用宽度,高度=image.size。我也这么做了。但我发现了这个错误,所以我检查了image.size的内容,得到了6220800。那么,我在这里做错了什么呢?

正如@TheLoverter4865在评论中所说的那样,
img.size
返回一个整数,不能解包

您需要做的是:

   (C:\Users\SACHIN\Anaconda2) D:\>python R6extractor.py
    6220800
    Traceback (most recent call last):
      File "R6extractor.py", line 14, in <module>
        width , height = img.size
    TypeError: 'int' object is not iterable
编辑

如果要使用
图像
库打开它,代码如下:

height, width, channels = img.shape

正如@TheLoverter4865在评论中所说,
img.size
返回一个整数,而您无法将其解包

您需要做的是:

   (C:\Users\SACHIN\Anaconda2) D:\>python R6extractor.py
    6220800
    Traceback (most recent call last):
      File "R6extractor.py", line 14, in <module>
        width , height = img.size
    TypeError: 'int' object is not iterable
编辑

如果要使用
图像
库打开它,代码如下:

height, width, channels = img.shape

大小不返回维度-无法使用元组解包来解包整数。检查PIL文档中的方法。但是这个和这个问题大小并没有返回维度——你不能用元组解包来解包整数。检查PIL文档中的方法。但是这个问题和这个问题我会接受这个作为答案,但是你能澄清一下这个问题的工作原理吗?在文档中,他们通过
image.open
方法打开图像。在您的代码中,您使用的是
cv2.imread
。因此,如果我使用open,我实际上可以使用image.size?编辑答案我将接受此作为答案,但您能否澄清此问题的工作原理,并且在文档中,他们通过
image.open
方法打开图像。在您的代码中,您使用的是
cv2.imread
。因此,如果我使用open,我可以实际使用image.size?编辑答案