鱼C论坛

 找回密码
 立即注册
查看: 3501|回复: 7

[已解决]itchat模块的不明错误

[复制链接]
发表于 2018-3-31 10:09:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 louxinghao 于 2018-3-31 22:08 编辑

这是一个利用微信 " filehelper " 进行操控微信播放音乐的一个小程序,但是运行后出现了一些不明白的错误,求大神帮忙看一下是什么问题,感谢感谢!

  1. import os
  2. import itchat
  3. from NetEaseMusicApi import interact_select_song

  4. with open('stop.mp3', 'w') as f:
  5.     pass

  6. def close_music():
  7.     os.starfile('stop.mp3')

  8. @itchat.msg_register(itchat.content.TEXT)
  9. def music_player(msg):
  10.     if msg['ToUserName'] != 'filehelper':
  11.         return
  12.     if msg['Text'] == u'关闭':
  13.         close_music()
  14.         itchat.send(u'音乐已关闭', 'filehelper')
  15.     if msg['Text'] == '帮助':
  16.         itchat.send(u'帮助信息', 'filehelper')
  17.     else:
  18.         itchat.send(interact_select_song(msg['Text']), 'filehelper')

  19. itchat.auto_login(True)
  20. 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:41:15
本帖最后由 瞬秒爆加速 于 2018-4-3 00:51 编辑
louxinghao 发表于 2018-3-31 11:34
所以这个是模块的问题吗还是怎样,请问要如何解决这个问题呢


我运行你的代码,没有报错,估计是处在播放音乐那里,你检查一下停止音乐的函数
os.starfile('stop.mp3') X
os.startfile('stop.mp3')
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-3-31 11:04:26 | 显示全部楼层
本帖最后由 瞬秒爆加速 于 2018-3-31 11:07 编辑

itchat.send(interact_select_song(msg['Text']), 'filehelper')  没有发现传值
song = api.song.detail(songId)[0]  导致这里没传值
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-3-31 11:34:01 | 显示全部楼层
瞬秒爆加速 发表于 2018-3-31 11:04
itchat.send(interact_select_song(msg['Text']), 'filehelper')  没有发现传值
song = api.song.detail( ...


所以这个是模块的问题吗还是怎样,请问要如何解决这个问题呢
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-3-31 22:05:02 | 显示全部楼层
求助求助~~
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-4-1 09:46:30 | 显示全部楼层
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2018-4-3 00:41:15 | 显示全部楼层    本楼为最佳答案   
本帖最后由 瞬秒爆加速 于 2018-4-3 00:51 编辑
louxinghao 发表于 2018-3-31 11:34
所以这个是模块的问题吗还是怎样,请问要如何解决这个问题呢


我运行你的代码,没有报错,估计是处在播放音乐那里,你检查一下停止音乐的函数
os.starfile('stop.mp3') X
os.startfile('stop.mp3')
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2018-4-4 21:19:57 | 显示全部楼层
瞬秒爆加速 发表于 2018-4-3 00:41
我运行你的代码,没有报错,估计是处在播放音乐那里,你检查一下停止音乐的函数
os.starfile('stop.mp3') ...

一开始是可以查询到歌曲的,但是输入数字选择歌曲的时候就会报出这样的错误,为什么会这样= =
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-17 09:03:27 | 显示全部楼层
想问楼主解决问题了吗,求指导
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-3-10 00:51

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表