gpt4 book ai didi

python - 更改桌面背景和播放 .mp3 文件不起作用

转载 作者:行者123 更新时间:2023-12-03 02:31:30 25 4
gpt4 key购买 nike

import ctypes
import winsound
SPI_SETDESKWALLPAPER = 20
while (True):
x = input("Enter Password. ")
if x == "blyat":
print ("motherland russia")
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, "D:\\VS Code Project\\COMMUNISM.jpg", 0)
winsound.PlaySound("USSR Anthem.mp3", winsound.SND_FILENAME)

当我运行程序时,我听不到 .mp3 并且桌面背景变黑而不是更改为我选择的图像(COMMUNISM.jpg)

最佳答案

根据您提供的信息,我做了以下工作:

  • 安装模块“playsound”并将其添加到使用:(pip install playsound)

  • from playsound import playsound


  • 使用“playsound('D:\\...\\Ze\\1.mp3')”代替“winsound.PlaySound("D:\\...\\Ze\\1.mp3", winsound.SND_FILENAME)

  • 完整代码:
    from playsound import playsound  
    import ctypes
    import winsound
    SPI_SETDESKWALLPAPER = 20
    while (True):
    x = input("Enter Password:")
    if x == "blyat":
    print ("motherland russia")

    ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, "D:\\...\\Ze\\1.jpg", 0)
    # winsound.PlaySound("D:\\...\\Ze\\1.mp3", winsound.SND_FILENAME)
    playsound('D:\\...\\Ze\\1.mp3')

    我在电脑上测试的结果是桌面壁纸换了,播放了mp3。

    关于python - 更改桌面背景和播放 .mp3 文件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64670963/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com