Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/339.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
Python在两个gif图像上应用逻辑异或函数返回错误值error:image具有错误模式_Python_Encryption_Python Imaging Library_Xor - Fatal编程技术网

Python在两个gif图像上应用逻辑异或函数返回错误值error:image具有错误模式

Python在两个gif图像上应用逻辑异或函数返回错误值error:image具有错误模式,python,encryption,python-imaging-library,xor,Python,Encryption,Python Imaging Library,Xor,我有两个gif图像,我需要从库中对它们执行逻辑异或 这是我的代码: 我得到这个错误: True 回溯(最近一次呼叫最后一次): 文件“C:/Users/negut_000/OneDrive/Scoala/Crypto/Image Encrypt-Decrypt-OTP/Encrypt.py”,第24行,在 secret=逻辑异或(图像、密钥) 文件“C:/Users/negut\u 000/OneDrive/Scoala/Crypto/Image Encrypt-Decrypt-OTP/Enc

我有两个gif图像,我需要从库中对它们执行逻辑异或 这是我的代码:

我得到这个错误:

True
回溯(最近一次呼叫最后一次):
文件“C:/Users/negut_000/OneDrive/Scoala/Crypto/Image Encrypt-Decrypt-OTP/Encrypt.py”,第24行,在
secret=逻辑异或(图像、密钥)
文件“C:/Users/negut\u 000/OneDrive/Scoala/Crypto/Image Encrypt-Decrypt-OTP/Encrypt.py”,第21行,逻辑异或
返回image1.\u new(image1.im.chop\u xor(image2.im))
ValueError:图像的模式错误
进程已完成,退出代码为1
看起来图像的模式是一样的,所以我不理解这个问题。 请帮忙

使用而不是

image = Image.open("image.gif", mode='r').convert("1")
key = Image.open("key.gif", mode='r').convert("1")
此代码

   image = Image.open("image.gif")
   key = Image.open("key.gif")
image = Image.open("image.gif", mode='r').convert("1")
key = Image.open("key.gif", mode='r').convert("1")