save_info.py:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import itchat
import pickle
itchat.auto_login(hotReload=True)
itchat.dump_login_status() friends = itchat.get_friends(update=True)[:] def save_obj(obj, name ):
with open(name + '.pkl', 'wb') as f:
pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL) save_obj(friends,'friends')
show_info.py
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import pickle
def load_obj(name ):
with open( name + '.pkl', 'rb') as f:
return pickle.load(f) friends = load_obj('friends')
total = len(friends) - 1
man = women = other = 0 for friend in friends[0:] :
sex = friend["Sex"] if sex == 1 :
man += 1
elif sex == 2 :
women += 1
else :
other += 1 print u'姓名:{} 昵称:{} 格言{}'.format(friend["RemarkName"],friend["NickName"],friend["Signature"]) ss = '