【发布时间】:2016-12-07 12:37:34
【问题描述】:
我正在尝试将图像作为我的桌面图像。
我的图片路径:
#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)
现在问题是找到了图像路径,它也打开了一个图像。但是不是将打开的图像设置为桌面图像,它只是让我的桌面图像变黑。
【问题讨论】:
-
很高兴您找到了答案 :)
标签: python image python-2.7 ctypes desktop