python出现 'module' object is not callable错误

用Python显示图像出现 'module' object is not callable的错误

python出现 'module' object is not callable错误_第1张图片

可以将上述的代码改成如下的方式

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
#from matplotlib.image import imread
img = mpimg.imread('timg.jpg')
plt.imshow(img)
plt.show()

效果如下图:

python出现 'module' object is not callable错误_第2张图片

也可以用下面的方式:

import matplotlib.pyplot as plt
from matplotlib.image import imread
img = imread('timg.jpg')
plt.imshow(img)
plt.show()

还有一定要注意不要中英文空格混用,不然会出现

invalid character in identifier的错误!!!!

你可能感兴趣的:(编程,Python)