|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 louxinghao 于 2018-3-31 22:08 编辑
这是一个利用微信 " filehelper " 进行操控微信播放音乐的一个小程序,但是运行后出现了一些不明白的错误,求大神帮忙看一下是什么问题,感谢感谢!
- import os
- import itchat
- from NetEaseMusicApi import interact_select_song
- with open('stop.mp3', 'w') as f:
- pass
- def close_music():
- os.starfile('stop.mp3')
- @itchat.msg_register(itchat.content.TEXT)
- def music_player(msg):
- if msg['ToUserName'] != 'filehelper':
- return
- if msg['Text'] == u'关闭':
- close_music()
- itchat.send(u'音乐已关闭', 'filehelper')
- if msg['Text'] == '帮助':
- itchat.send(u'帮助信息', 'filehelper')
- else:
- itchat.send(interact_select_song(msg['Text']), 'filehelper')
- itchat.auto_login(True)
- itchat.run()
复制代码
运行后会出现如下错误
=================== RESTART: D:\python\python ex\wechatmusic.py ===================
█
Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Please press confirm on your phone.
Loading the contact, this may take a little while.
Login successfully as 星浩
Start auto replying.
Traceback (most recent call last):
File "D:\python\lib\site-packages\itchat\components\register.py", line 60, in configured_reply
r = replyFn(msg)
File "D:\python\python ex\wechatmusic.py", line 21, in music_player
itchat.send(interact_select_song(msg['Text']), 'filehelper')
File "D:\python\lib\site-packages\NetEaseMusicApi\SortedApi.py", line 146, in interact_select_song
r = iss.send(msgInput)
File "D:\python\lib\site-packages\NetEaseMusicApi\SortedApi.py", line 132, in _interact_select_song
song = api.song.detail(songId)[0]
TypeError: 'NoneType' object is not subscriptable
本帖最后由 瞬秒爆加速 于 2018-4-3 00:51 编辑
我运行你的代码,没有报错,估计是处在播放音乐那里,你检查一下停止音乐的函数
os.starfile('stop.mp3') X
os.startfile('stop.mp3')
|
|