擅长:python、mysql、java
<p>如果您使用的是python3,那么应该使用<code>ctypes.windll.user32.SystemParametersInfoW</code>而不是{<cd2>}(W而不是{a1}所说的)。
<a href="https://stackoverflow.com/a/27726289/6202760">Another answer</a>描述了这一点,因为在python3中,<code>str</code>类型是UTF-16的形式,在C中是<code>wchar_t *</code></p>
<p>另外,请将代码最小化,如下所示:</p>
<pre><code>import time;
import ctypes;
SPI_SETDESKWALLPAPER = 20
wallpapers = r"C:\Users\Owner\Documents\Wallpaper\%d.jpg"
localtime = time.localtime(time.time())
wkd = localtime[6]
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, wallpapers%(wkd+1), 0)
</code></pre>
<p>不要重复你自己。在</p>