注册 登录
编程论坛 Python论坛

新手调试程序总出现莫名奇妙的错误,求大家指点

枕上卢生 发布于 2020-02-05 03:07, 1552 次点击
大家好,我是一个python新手,刚入门,想写一个获取微信群成员头像的代码,课是调试时总出弦如下错误,还求大家指点。谢谢大家。
错误:

Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Thread-17Exception in thread Exception in thread Exception in thread Exception in thread Thread-18Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Thread-19Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Thread-20Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread Exception in thread

我的代码:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from wxpy import *
import threading
import os
import time

class wechatInfo (object):
    # 初始化微信
    def __init__ (self):
        self.bot = Bot()
        self.myself = self.bot.self
        self.friends = self.bot.friends()
        # self.tuling = Tuling(api_key='ad68c7fe6caf4d29bb78fe36cbbf1b63')

    def main (self):
        if not os.path.exists('./info/' + wechat.myself.name):
            filepath = os.getcwd()
            os.makedirs(filepath + '/info/' + wechat.myself.name + '/headImg')
            self.getGroupsList()

    # 获取群列表
    def getGroupsList (self):
        groups = self.bot.groups()
        print(groups)
        for i in range(len(groups)):
            group = groups[i]
            for f in range(len(group.members)):
                if f == 0:
                    writeType = 'w'
                else:
                    writeType = 'a'

                t = threading.Thread(target=self.saveHeadImg, args=(group.members[f],))
                t.start()

    # 保存头像
    def saveHeadImg (groups, member):
        print('正在保存 %s 的头像...' % member.name)
        groups.get_avatar('info/%s/headImg/%s_%s.jpg' % (self.myself.name, member.name[:20], time.time()))


    # def reply_msg(self, msg):
    #     self.tuling(msg)

if __name__ == "__main__":
    wechat = wechatInfo()
    wechat.main()

1 回复
#2
wp2319572020-02-06 08:42
微信网页端口被腾讯关闭了,玩不了了
1