用Python寫了個函式,顯示在線的圖片。
測驗下來,若是https協議,有些報錯,有些報警
若是http協議,則全部正確
運行錯誤:https://jy.hpe.cn/wcm.files/upload/CMSjy/202012/20201228160633720.jpg
錯誤資訊:PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000001ECB12DC7C0>
運行報警:https://www.shssp.org/UploadFiles/image/20210304/6375045061511984482248498.png
報警資訊:InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.shssp.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
運行正確:http://www.tjyfz1.edu.sh.cn/cjcx/fankuixinxi/uploadfile/1(20210204222541198).jpg
from PIL import Image, ImageDraw
from io import BytesIO
import requests as req
def showimage():
global img
global img_src
img_src=https://bbs.csdn.net/topics/entry1.get()
response = req.get(img_src,verify=False)
img = Image.open(BytesIO(response.content))
img.show()
uj5u.com熱心網友回復:
Adding certificate verification is strongly advised.在瀏覽器中添加信任證書
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/266821.html
