Home > other >  Warrior directions of written in Python, a function to display an online photo (some URL is correct,
Warrior directions of written in Python, a function to display an online photo (some URL is correct,

Time:03-07

Written in Python function, according to an online photo,

Test, if the HTTPS protocol, some error, some alarm
If the HTTP protocol, all right

Runtime error: https://jy.hpe.cn/wcm.files/upload/CMSjy/202012/20201228160633720.jpg
Error message: PIL. UnidentifiedImageError: always identify the image file & lt; _io. BytesIO object at 0 x000001ecb12dc7c0 & gt;

Run the alarm: https://www.shssp.org/UploadFiles/image/20210304/6375045061511984482248498.png
Alarm message: InsecureRequestWarning: Unverified HTTPS request is being made to the host 'www.shssp.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

Run right: http://www.tjyfz1.edu.sh.cn/cjcx/fankuixinxi/uploadfile/1 (20210204222541198). JPG


The from PIL import Image, ImageDraw
The from IO import BytesIO
The import requests as the req

Def showimage () :
Global img
Global img_src
img_src=https://bbs.csdn.net/topics/entry1.get ()
The response=the req. Get (img_src, verify=False)
Img=Image. Open (BytesIO (response. The content))
Img. The show ()

CodePudding user response:

Adding certificate verification is strongly advised.
Add trust certificate in your browser
  • Related