我正在尝试循环某些像素并使用 PixelAccess
对其进行编辑。由于某种原因,当我尝试设置像素时,Python 给出了 TypeError: function gets正好 1 个参数(给定 4 个)
pixels[(x, y)] = pix
是确切的代码。
Traceback (most recent call last):
File "./gen_shuttletiles.py", line 86, in <module>
main()
File "./gen_shuttletiles.py", line 76, in main
pixels[(x, y)] = pix
TypeError: function takes exactly 1 argument (4 given)
pix
是图像 RGBA 值的 4 元组数字。
我尝试通过添加一些零来更改元组中项目的数量,并且错误中给出的计数确实增加了。
最佳答案
我发现,图像处于 P
模式,因此我必须事先将其转换为 RGBA
。
关于python - 枕头 PixelAccess 类型错误 : function takes exactly 1 argument (4 given),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43528019/