知识来源:https://zhuanlan.zhihu.com/p/73975013

1.环境

os:MAC

tool:python 3.7 ,pip3.7

2.前提:

使用pip3.7 install pillow and wxpy 模块

3.开始:

 from wxpy import *
import PIL.Image as Image
import os
import sys
#登陆微信
bot = Bot(console_qr=2,cache_path="botoo.pkl")
#获取当前路径
curr_dir = os.path.abspath(sys.argv[0])
#创建文件夹,用来放照片
if not os.path.exists(curr_dir + "FriendImages/"):
os.mkdir(curr_dir + "FriendImages/")
#获取朋友的头像
my_friends = bot.friends(update=True)
n = 0
for friend in my_friends:
friend.get_avatar(curr_dir + "FriendImages/" + str(n) + ".jpg")
n = n+1
#首先设定照片墙的大小,尺寸(650*650)
image = Image.new("RGB",(850,850))
x = 0
y = 0
#获取之前放照片的位置
curr_dir = os.path.abspath(sys.argv[0])
#逐个获取照片
ls = os.listdir(curr_dir + "FriendImages")
for file_names in ls:
try:
img = Image.open(curr_dir + "FriendImages/" + file_names)
except IOError:
continue
else:
#设定好友头像的大小,为50*50
img = img.resize((50,50),Image.ANTIALIAS)
image.paste(img,(x*50,y*50))
x += 1
if x ==17:
x = 0
y += 1
img = image.save(curr_dir + "wechat_friend_wall.jpg")
#最终生成17*17个头像的一个照片墙

最新文章

  1. tomcat 假死现象(转)
  2. 学习Coding-iOS开源项目日志(一)
  3. C代码中如何调用C++ C++中如何调用C
  4. txt用Itunes同步到IPhone上
  5. C# DateTime和DateTime?格式化时间
  6. How to Make LastPass Even More Secure with Google Authenticator
  7. UPC 2959: Caoshen like math 这就是个水题
  8. Android使用OpenGL ES2.0显示YUV,您的手机上的数据要解决两个方面的坐标
  9. C语言 - 预编译
  10. DynamicXml
  11. 推荐一款接口文档在线管理系统-MinDoc
  12. IDEA编写css样式报错
  13. css解决内联元素间的空白间隔
  14. C#File类常用文件操作以及一个模拟的控制台文件管理系统
  15. Kotlin Native
  16. makefile编写规则
  17. 腾讯 xtestserver 基本使用教程~
  18. HDU 2012 素数判定
  19. OneNET麒麟座应用开发之十:空气质量数据监测站项目总结
  20. sklearn linear_model,svm,tree,naive bayes,ensemble

热门文章

  1. pytorch 中LSTM模型获取最后一层的输出结果,单向或双向
  2. 使用 Junit + Mockito 实践单元测试
  3. Jenkins(3)- 安装Jenkins过程中遇到问题的排查思路
  4. ISO及安全业务,机制
  5. MySql -- 数据结构
  6. Spring框架中文件目录遍历漏洞 Directory traversal in Spring framework
  7. hexo-themes-setting
  8. 【高并发】由InterruptedException异常引发的思考
  9. HR问了我朋友什么是简单工厂模式,竟被质疑是否学过设计模式,是否是计算机专业?
  10. Codeforce-Ozon Tech Challenge 2020-A. Kuroni and the Gifts