Home  >  Article  >  Backend Development  >  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)

烟雨青岚
烟雨青岚forward
2020-06-20 13:30:543663browse

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

itchat and wxpy, and the bottom layer of wxpy is called itchat, so if you just want to use it, it is recommended to use wxpy library, it is more elegant than other libraries, more object-oriented, and deeply integrated with Turing Robot and 小i Robot; and itchatThe scalability is better. If you want to develop your own WeChat library, it is recommended to choose itchat.

2. Implementation principle

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

wxpy (the bottom layer uses itchat ) library is to simulate logging into the web page, and then call WeChat's API to implement the operation. We can check the itchat source 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,
Currently wxpy and itchat are 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 Interpreter wxpyБиблиотека.
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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete
Previous article:Sorting Python dictionaryNext article:Sorting Python dictionary