给手机助手发送消息
import itchat
import time
import random
itchat.auto_login()
for i in range(3):
itchat.send('hello',toUserName='filehelper')
time.sleep(1)
####统计男女比例
import itchat
import time
import random
itchat.auto_login()
ccc = {}
ss = itchat.get_friends()
for i in ss[1:]:
if i['Sex'] == 1:
ccc['male'] = ccc.get('male', 0) + 1
elif i['Sex'] == 2:
ccc['female'] = ccc.get('female', 0) + 1
else:
ccc['other'] = ccc.get('other', 0) + 1
print(ccc)
##其中 dict.get('male',0) 如果有值就加1,没有值就返回0,0是默认值