作者:风一样的骨头gg | 来源:互联网 | 2023-05-17 11:49
#与好友聊天小程序importitchatitchat.auto_login(hotReloadTrue)friendsitchat.get_friends()yourin
# 与好友聊天小程序
import itchat
itchat.auto_login(hotReload=True)
friends = itchat.get_friends()
yourinput = input("请输入好友昵称: ")
yourmessage = input("请输入发送内容:")
for friend in friends:
if friend['NickName'] == yourinput:
itchat.send(yourmessage,toUserName=friend['UserName'])
# 运行结果如下:
C:\Users\cz\AppData\Local\Programs\Python\Python35\python.exe E:/Python/python高阶/44.py
Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Please press confirm on your phone.
Loading the contact, this may take a little while.
Login successfully as 韩兵
请输入好友昵称: 章继
请输入发送内容:hello
Process finished with exit code 0
# 请先扫码登录再发送
兄弟连学python
Python学习交流、资源共享群:563626388 QQ