21 lines
651 B
Python
21 lines
651 B
Python
import requests
|
|
from PIL import Image
|
|
from io import BytesIO
|
|
|
|
# 图片的完整 URL
|
|
Avatar_url = "https://u.sunderer.games/storage/default/20241222/我的世界-minecraft_9478e13cb10ec60f31a7674a80417f0046cdff0b.png"
|
|
|
|
# 发送 GET 请求获取图片数据
|
|
response = requests.get(Avatar_url)
|
|
|
|
# 检查请求是否成功
|
|
if response.status_code == 200:
|
|
# 使用 PIL 打开图片
|
|
img = Image.open(BytesIO(response.content)) # 将字节数据转换为图像
|
|
#img.show() # 显示图片
|
|
else:
|
|
print(f"图片下载失败,状态码: {response.status_code}")
|
|
|
|
|
|
Avatar = Image.open(BytesIO((requests.get(Avatar_url).content)))
|
|
Avatar.show() |