我正在尝试制作一张图像作为我的桌面图像。
我的图片路径:为什么我的桌面屏幕变黑?
#Image Path
import random,os
folder= r"C:\\Users\rkp10\AppData\Local\Google\Chrome\User Data\Default\Extensions\laookkfknpbbblfpciffpaejjkokdgca\0.91.6_0\backgrounds"
a=random.choice(os.listdir(folder))
print(a)
打开图像:
#Opening the Image
from PIL import Image
file = folder+'\\'+a
Image.open(file).show()
使图像作为我的桌面图像:
#Making the image as desktop image
import ctypes
image_path = file
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, image_path, 3)
现在的事情是图像路径被发现,它也会打开一个图像。但不是将打开的图像设置为桌面图像,而是将我的桌面图像设为黑色。
很好的了解,你找到了答案:) – ABcDexter