私は Python を初めて使用し、背景を Nation Geographic Picture of the Day に変更するプログラムを作成しているときに問題に遭遇しました。jpegへのパスは問題なく取得できますが、コマンドを使用してデスクトップの背景を変更すると(Windowsの場合)、背景が真っ黒に変わります。コード自体はエラーをスローしません。私が望んでいたように機能していません。これがコードです。
import urllib2
import ctypes
SPI_SETDESKWALLPAPER = 20
url = urllib2.urlopen("http://photography.nationalgeographic.com/photography/photo-of-the-day/")
code = url.readlines()
pos = code[1303].split("\"",2)
imgurl = pos[1]
print imgurl
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, imgurl , 0)