當我使用PIL時,必須導入大量的PIL模塊。我用三種方式嘗試做到這一點,但只有最後一部作品,儘管所有的都是邏輯對我說:爲什麼我的Python PIL導入不起作用?
導入完整PIL並調用它的模塊代碼:沒
>>> import PIL
>>> image = PIL.Image.new('1', (100,100), 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Image'
導入一切從PIL:沒
>>> from PIL import *
>>> image = Image.new('1', (100,100), 0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Image' is not defined
導入一些模塊由PIL:OK
>>> from PIL import Image
>>> image = Image.new('1', (100,100), 0)
>>> image
<PIL.Image.Image image mode=1 size=100x100 at 0xB6C10F30>
>>> # works...
我沒有在這裏得到什麼?