python第三方库文件传输助手_Python中的第三方模块(itchat)

准备工作:

pycharm导入第三方模块的包

1.ctrl+alt+s进入settings,选择Project下的Project Interpreter

2.点击右上角的加号,进入之后搜索qrcode,选择install

安装成功之后会提示

3.搜索itchat,同样install,安装成功之后esc退出,选择ok即可

练习1:扫描二维码后文件传输助手会一直发送hello

import itchat

itchat.auto_login()

while True:

itchat.send('hello',toUserName='filehelper')

练习2:扫描二维码之后和会一直发送文件

import random

import time

import itchat

itchat.auto_login()

while True:

itchat.send_file('/etc/passwd', toUserName='filehelper')

time.sleep(random.randint(1,3))

练习3:统计微信好友中男性,女性还有其他的数量

import itchat

itchat.auto_login()

friends = itchat.get_friends()

info = {}

for friend in friends[1:]:

if friend['Sex'] == 1:

info['male'] = info.get('male',0) + 1

elif friend['Sex'] == 2:

info['female'] = info.get('female',0) + 1

else:

info['other'] = info.get('other',0) + 1

print(info)

##执行之后会生成一个二维码,扫描二维码,点击登陆即可在出现结果

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 孤岛

{'male': 68, 'female': 78, 'other': 10}

标签:info,code,get,Python,itchat,二维码,模块,import

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值