如何拥有够酷炫逼格够高的桌面?本文教你轻松定制自己的桌面背景



def crawlWallpaper(cache_dir='download'): checkDir(cache_dir) url_base = 'http://himawari8-dl.nict.go.jp/himawari8/img/D531106/1d/550/' date = datetime.datetime.utcnow().strftime('%Y/%m/%d/')# 卫星图更新到网站上是有时延的 hour = str(int(datetime.datetime.utcnow().strftime('%H')) - 1).zfill(2) minute = str(datetime.datetime.utcnow().strftime('%M'))[0] + '0' second = '00' ext = '_0_0.png' picture_url = url_base + date + hour + minute + second + ext res = requests.get(picture_url)with open(os.path.join(cache_dir, 'cache_wallpaper.png'), 'wb') as f: f.write(res.content)
def setWallpaper(image_path): key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,"Control Panel\\Desktop",0,win32con.KEY_SET_VALUE) win32api.RegSetValueEx(key, "WallpaperStyle", 0, win32con.REG_SZ, "2") win32api.RegSetValueEx(key, "TileWallpaper", 0, win32con.REG_SZ, "0") win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER,image_path, 1+2)
filepath = os.path.split(os.path.realpath(__file__))[0] + '\download'print(filepath)
image_name='cache_wallpaper.png'
image_path = filepath + '\\' + image_namesetWallpaper(image_path)

源码下载
公众号后台回复关键词:卫星图
