Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)

烟雨青岚
Release: 2020-06-20 14:14:11
forward
3622 people have browsed it

Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)

## Learn to use Python to implement WeChat robots in eight hours Functions (detailed explanations with pictures and texts)

WeChat, a super app with 1 billion daily users, not only dominates domestic social networking, but also occupies a place in foreign social networking. Today we are going to tell you how to use it Python to generate a WeChat robot, and suddenly I remembered what Mr. Lu Xun once said:


Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)Because it is the first article in the WeChat robot series, Brother Zhu will explain every place in detail, Try our best to enable every student who wants to learn to start smoothly. Let’s do something interesting together!

Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)1. Project introduction

1. WeChat library selection

python about developing WeChat The libraries mainly include

itchatandwxpy, and the bottom layer ofwxpyis calleditchat, so if you just want to use it, it is recommended to usewxpylibrary, it is more elegant than other libraries, more object-oriented, and deeply integrated withTuring Robotand小i Robot; anditchatThe scalability is better. If you want to develop your own WeChat library, it is recommended to chooseitchat.

2. Implementation principle

I believe that many students have used the web version of WeChat, and

wxpy(the bottom layer usesitchat) library is to simulate logging into the web page, and then call WeChat's API to implement the operation. We can check theitchatsource code to find out.
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)In short, please remember,
Currentlywxpyanditchatare operated by simulating the web version of WeChat.

3. Turing Robot

Now that we can simulate web WeChat, how can we automatically reply? Here we use

Tulin Robot. You can register an account for free on their official website (http://www.tuling123.com), and then apply for a free robot. Each person can apply for up to five for free. robot.
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)I will give a default apikey in the project code so that everyone can try it without downloading it, but it is still recommended to apply for it yourself, because this default apikey has a limit on the number of calls, and it is considered a What a free fortune!

4. Overall process

In order to facilitate everyone’s understanding, Brother Zhu drew a timing diagram for everyone


Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)

2. Project code

First let’s take a look at the project structure diagram:


Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)

1. Download Project

Brother Zhu has put the project on GitHub. Some friends in the group reported that they don’t know how to use github. Here I will explain in detail how to download the project from github.

Note: github and git are not the same thing. Github is the world's largest gay dating forum. Here we don't compare with appearance and wealth, but only with projects that have more

star, the more stars you have, the more you attract the likes and admiration of the same sex, and even your colleagues will fall in love with you! Git is a project management tool. Projects on github are managed with git. Another faction of project management tools is svn.

Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)
Сначала найдите проект, который нужно загрузить, затем нажмитеКлонировать или загрузить, а затем нажмите кнопку копирования справа. Адрес проекта брата Чжу: : https: //github.com/pig6/wxrobot
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)
Затем откройте pycharm и выберитеCSV->Оформить заказ из системы контроля версий->git, а затем вставьте только что скопированную ссылку на проект.
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)
Наконец, pycharm может подсказать вам, открывать ли в новом окне или в текущем окне. Брат Чжу обычно привык открывать в новом окне (новое окно), что позволяет избежать нескольких проектов. Создает путаницу при разработке.

2.Загрузка библиотеки wxpy

После загрузки проекта, поскольку необходимая библиотекаwxpyне установлена, pycharm Возможно, появится следующее приглашение, и мы сможем нажать «Установить».
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)
Если приглашение на установку библиотеки не появляется, мы можем добавить ее вSetting->Project->Project InterpreterwxpyБиблиотека.
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)
Или используйте следующую команду, чтобы загрузить библиотекуwxpy. Если вы используете pip3, замените приведенный ниже pip.

pip install -U wxpy -i «https://pypi.doubanio.com/simple/»

3. Запустите проект

Вы можете нажать кнопку зеленого треугольника в правом верхнем углу или щелкнуть проект правой кнопкой мыши и нажатьLearn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text).
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)
После запуска появится QR-код для входа. Отсканируйте его с помощью WeChat на своем мобильном телефоне и нажмите «ОК», чтобы войти в систему и пообщаться с друзьями.
Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text)

Прежде всего, спасибо за ваше терпение при чтении. Учитывая, что есть много студентов, не имеющих базовых знаний, статья немного длинная.

Эта статья воспроизведена по адресу: https://blog.csdn.net/u014044812/article/details/89406010

## Рекомендуемый учебник: "

python учебник"

The above is the detailed content of Learn to use Python to implement WeChat robot functions in eight hours (detailed explanation with pictures and text). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!