Python Image模块在Image.open()之后没有属性

2024-09-22 16:35:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码是这样的 code

filename = 'X:'+os.sep+'premiere'+os.sep+'pic'+os.sep+'bg.png'
im = Image.open(filename)
print im
print type(im)
print dir(type(im))

我可以打印的im类型是PngImageFile。 im's type

<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=3508x2480 at 0x33BE550>
<class 'PIL.PngImagePlugin.PngImageFile'>
['_Image__transformer', '__class__', '__copy__', '__delattr__', '__dict__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__getattr__', '__getattribute__', '__getstate__'........]

但是我不能在im上使用PngImageFile的任何属性。有人能告诉我为什么吗,我很困惑。你知道吗


Tags: 代码imagepilostypecodefilenamesep