能不能说一张清单。现在我在用
#Minimum reproducable
import tkinter as tk
from gtts import gTTS
from io import BytesIO
import pygame
def play():
words = [one,boy,girl,man,woman,two]
for i in words:
speak(i)
def speak(text,language="en",accent="com"):
mp3_fp = BytesIO()
phra
每当我运行我的代码时,我都会得到这个错误:
NameError: name 'pygame' is not defined
这是我的密码:
from tkinter import *
from tkinter import filedialog
from pygame import mixer
from pygame.locals import *
class MusicPlayer:
def __init__(self, window ):
window.geometry('320x100'); window.title(
我是这里的新手,我正在尝试制作一个简单的程序,在python中播放洗牌音乐。
我试过使用pygame.mixer.music和list变量来选择一首随机歌曲并播放它。记住,我是全新的,不知道自己在做什么。
import pygame
from pygame.locals import *
import random
import pygame.mixer
L = ['Relax.mp3', 'Wanchu_Back.mp3', 'Some_Chords.mp3', 'Green_Gusher.mp3',]
S = random
我目前正在用python开发一个自动点唱机/音乐播放器。为了使代码更有条理,我将其组织到特定的类中。一些外部函数需要访问类变量并更新它们。但是,程序会抛出以下错误:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 1702, in __call__
return self.func(*args)
File "jukeboxDraft.py", line 77, in nextSong
constr
from tkinter import*
window = Tk()
color=['red','blue','purple']
def chgcolor():
for i in color:
mybutton.config(bg=i)
window.title('my first python gui')
mybutton=Button(window,text='change color',command=chgcolor)
mybutton.pack()
window.mainlo
编辑:将GPIO.PUD_UP替换为GPIO.PUD_DOWN,this循环现在如下所示:
playing = False
while True:
if GPIO.input(26)==False:
if not playing:
pygame.mixer.music.play()
playing = True
else:
if playing:
pygame.mixer.music.stop()
playing = False
我试着在打开门的时候放音乐,用树莓皮零WH和霍尔效应传感器来做。我对p