程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

10 minutes to teach you to download and splice wechat friends avatars with Python

編輯:Python

I believe wechat can't be used more . that , about python+ WeChat , What new tricks can we play ? Now I'll bring you a funny thing . use python Download the avatars of all wechat friends , And then put it together into a big picture . such , You can reprint it to the circle of friends XY 了 . ha-ha .

Let's first show you the renderings . After all, there is no plan X.


All right, no more nonsense , Let's see how we do it step by step .

Download wechat friend avatar

The first step, of course, is to download the avatar of wechat friends , Before splicing . Here we use itchat This python The library of . About this library , We will launch more interesting things later , Please pay attention and Just look forward to it . Look at the code first :


The code is often simple . First we call itchat.auto_login() Log in via wechat .

After scanning the code and logging in successfully , We get friends again , Then get the avatar , Configure the file saving path again , Finally, write the avatar into the file . Is it incredibly simple ?

Splicing friends' avatars

Splicing we used PIL In the library Image modular . See the code below :


Let's start with os.listdir The path to get all the avatars is saved to pathList Inside . Then create a big picture , Divide the big picture into n A small square , Then put the picture of your friend in the small square . It should be noted that , In front of your friend's Avatar , The avatar needs to be shortened to fit . Last , Generate final file . You can find it in the current directory final.jpg. That is our finished product . You can take it to the circle of friends to force ~


About Python Technology reserve

Learn from good examples Python Whether it's employment or sideline, it's good to make money , But learn to Python Still have a learning plan . Finally, let's share a complete set of Python Learning materials , For those who want to learn Python Let's have a little help !

One 、Python Learning routes in all directions

Python All directions are Python Sort out the common technical points , Form a summary of knowledge points in various fields , The use of it is , You can find the corresponding learning resources according to the above knowledge points , Make sure you learn more comprehensively .

Two 、 Learning software

If a worker wants to do a good job, he must sharpen his tools first . Study Python Common development software is here , It saves you a lot of time .

3、 ... and 、 Getting started video

When we were watching videos to learn , You can't just move your eyes and brain without hands , A more scientific way to learn is to use them after understanding , At this time, the hand training program is very suitable .

Four 、 Practical cases

Optical theory is useless , Learn to knock together , Do it , Can you apply what you have learned to practice , At this time, we can make some practical cases to learn .

5、 ... and 、 Interview information

We learn Python Must be to find a well paid job , The following interview questions are from Ali 、 tencent 、 The latest interview materials of big Internet companies such as byte , And the leader Ali gave an authoritative answer , After brushing this set of interview materials, I believe everyone can find a satisfactory job .


This full version of Python A full set of learning materials has been uploaded CSDN, Friends can scan the bottom of wechat if necessary CSDN The official two-dimensional code is free 【 Guarantee 100% free


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved