我正在传递图像的URL以获取其大小(高度和宽度),但是python似乎无法获取此URL。我正在使用python 3.5
实际代码是:-
from urllib.request import urlopen
from PIL import Image
url = 'https://zdnet3.cbsistatic.com/hub/i/r/2014/12/01/f7247ce5-7921-11e4-b569-d4ae52e95e57/thumbnail/70x53/a5599f31ffa560131f54bcf8442e80ba/zd-defaultimage-news.jpg'
img = Image.open(urlopen(url))
print("Image size:", img.size)
我收到此错误:
“ OSError:无法识别图像文件<_io.BytesIO对象位于0x000002907E898308>”