python-----群发图片

使用wxpy库给3个人群发同一张图片

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/2/22 15:25
# @Author  : xiaodai
from wxpy import *
# 指定图片文件的路径
image_path = "demo.jpg"  #这里替换成你的图片路径
# 初始化微信机器人
bot = Bot()
# 将要发送的好友的名字存到list中
friends = ['','','']
# 定义用于群发操作的函数
def send_to_friends(friends):
    for friend in friends:
        # 搜素好友
        friend_search = bot.friends().search(friend)
        # 如果搜索结果仅有一个,则发送图片,否则返回错误信息
        if (len(friend_search) == 1):
            friend_search[0].send_image(image_path)
        else:
            print("发送失败!请检查用户名:"+friend)
# 调用函数
send_to_friends(friends)
原文地址:https://www.cnblogs.com/xiaodai0/p/10418676.html