话不多说,直接上代码
import itchat
import math
import PIL.Image as Image
import os
itchat.auto_login()
friends = itchat.get_friends(update=True)[0:]
user = friends[0]["UserName"]
num = 0for i in friends:
img = itchat.get_head_img(userName=i["UserName"])
fileImage = open('文件夹' + "/" + str(num) + ".jpg",'wb')
fileImage.write(img)
fileImage.close()
num += 1ls = os.listdir('文件夹')
each_size = int(math.sqrt(float(0*0)/len(ls)))
lines = int(0/each_size)
image = Image.new('RGBA', (0, 0))x = 0y = 0for i in range(0,len(ls)+1):try:
img = Image.open('文件夹' + "/" + str(i) + ".jpg")
except IOError:print("Error")else:
img = img.resize((each_size, each_size), Image.ANTIALIAS)
image.paste(img, (x * each_size, y * each_size))x += 1if x == lines:x = 0y += 1
image.save('文件夹' + "/" + "all.jpg")
itchat.send_image('文件夹' + "/" + "all.jpg", 'filehelper')pip install itchat pip install pillow
如果安装python的时候pip安装选项没打√ ,就先安装pip。
Python和pip的安装
代码运行过程中会出现登录二维码,用微信扫一下,你就可以看到处理的进度。一会你的微信文件传输助手就会收到拼接好的头像图片。
学习过程中遇到什么问题或者想获取学习资源的话,欢迎加入学习交流群
Copyright © 2019- nbmht.com 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务