簡體   English   中英

模塊 'PIL.Image' 沒有屬性 'load'

[英]module 'PIL.Image' has no attribute 'load'

image = Image.load(img)

這一行給了我錯誤。 我正在嘗試加載圖像。
AttributeError: module 'PIL.Image' has no attribute 'load'

改為這樣做:

from PIL import Image
image = Image.open("path_to_image.png")

將“path_to_image”替換為您的實際路徑。

請閱讀文檔: https : //pillow.readthedocs.io/en/stable/handbook/tutorial.html

  1. 如果你想獲得像素訪問對象,你必須:
img = Image.open("path/to/image")
img.load()
  1. 使用.load方法不是必需的,因為 Image 類在第一次訪問時會自動加載打開的圖像。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM