如何解决线程模块问题
| 所以我有代码:def Listen(filepath):
def play(filepath):
def play_music(music_file):
\"\"\"
stream music with mixer.music module in blocking manner
this will stream the sound from disk while playing
\"\"\"
clock = pygame.time.Clock()
pygame.mixer.music.load(music_file)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
# check if playback has finished
clock.tick(30)
# pick a MP3 or MIDI music file you have ...
# (if not in working folder,use full path)
music_file = filepath
#music_file = \"ChancesAre.mid\"
# set up the mixer
freq = 44100 # audio CD quality
bitsize = -16 # unsigned 16 bit
channels = 2 # 1 is mono,2 is stereo
buffer = 2048 # number of samples (experiment to get right sound)
pygame.mixer.init(freq,bitsize,channels,buffer)
# optional volume 0 to 1.0
pygame.mixer.music.set_volume(1.0)
play_music(music_file)
thread.start_new_thread(play,(filepath))
我得到一个错误:
File \"C:\\Users\\Desktop\\WhaleTunes.py\",line 59,in Listen
thread.start_new_thread(play,(filepath))
<type \'exceptions.TypeError\'>: 2nd arg must be a tuple
有谁知道我为什么会收到此错误?
解决方法
阅读TypeError消息:\“第二个arg必须是一个元组。\”您有
(filepath)
。这不是元组。一个元素的元组应写为:“ 3”以消除歧义。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。