我正在使用 python 3.7.4 和枕头库,我想向 Image 类添加方法。我试过了
def myFunc(self, a):
(do something)
Image.myFunc = myFunc
im = Image.new('RGBA', (w, h), 0)
im.myFunc(a)
但这给了我
Traceback (most recent call last):
File "...\main.py", line 755, in <module>
TooltipRender.render()
File "...\main.py", line 146, in render
img.put(frame_cover, (3, 3))
AttributeError: 'Image' object has no attribute 'put'
(我自己不写 im = Image(~) 可能有问题?)
我可以写myFunc(im, a),但我想要一些看起来更好的东西。