selfteaching / selfteaching/selfteaching-python-camp

Day12 微信搜索指定好友和import的问题

Open
#1,269 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Description

我的代码如下,有2个问题,请大神指教,谢谢!
第一,我的信息好像并没有发送给到指定的好友,是没有搜索到吗?不知道问题出在哪里。
第二,VS code 提示:Unable to import d11_training1。d11_training1.py 也贴在下面,请帮忙看看问题出在哪里。

d12_training2.py

from wxpy import Bot,Message,embed
import d11_training1

bot = Bot()
my_friend = bot.friends().search('老婆叶',city="深圳")[0]
my_friend.send('请分享文章,谢谢您!')
@bot.register(my_friend)
def get_msg(msg):
    if msg.type == 'Sharing':
        target_url = msg.url
        stats_msg = d11_training1.stats(target_url)
        msg.reply(stats_msg)
    else:
        pass
embed()

d11_training1.py

import requests
# import yagmail
from pyquery import PyQuery 
from mymodule import stats_word

def stats(url):
    response = requests.get(url)
    document = PyQuery(response.text)
    content = document('#js_content').text()

    statList = stats_word.stats_text(content,100)
    statString = ''.join(str(i) for i in statList)
    return statString

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running d12_training2.py and reading its imports, then inspect d11_training1.py and the reported Unable to import d11_training1 message. Verify the friend search and message callback behavior; done means the module imports successfully and the intended friend receives the request and can trigger a reply.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.