【发布时间】:2016-10-12 18:55:22
【问题描述】:
当我使用 PIL 时,我必须导入大量的 PIL 模块。我正在尝试三种方法来做到这一点,但只有最后一种方法对我来说是合乎逻辑的:
导入完整的 PIL 并在代码中调用它的模块:NOPE
>>> 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 导入所有内容:NOPE
>>> 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...
我在这里没有得到什么?
【问题讨论】:
标签: python python-3.x import python-import pillow