import itchat
#t = str.maketrans('','','\'')
dx = {"Uin": 0,"UserName":'',"NickName":'',"HeadImgUrl":'',"ContactFlag":'',"MemberCount":'',"MemberList":'',"RemarkName":'',"HideInputBarFlag":0,"Sex":0,"Signature":'',"VerifyFlag": 0,"OwnerUin": 0,"StarFriend":0,"AppAccountFlag": 0,"Statues": 0,"AttrStatus": 119911,"Province":'',"City":'',"Alias":'', "SnsFlag":0,"UniFriend": 0,"DisplayName":"","ChatRoomId": 0,"KeyWord":'',"EncryChatRoomId":''}
FriendList = []
rows = 0
clume = 0
keys = []
d = ' '
sALL = ' '
#name = []
def ADDdict(keys):
jian = keys[0].replace('\'','')
zhi = keys[1].replace('\'','')
if jian in dx:
return True
else:
return False
def EDITstr(strs):
x = []
a = ''
a = strs.replace(' ','')
for i in range(len(a)):
x.append(a[i])
for i in range(len(x)):
if i > 0 and x[i] == ',':
if not(x[i-1] == '\'' or x[i+1] == '\''):
print(str(i) + ' ' + x[i])
x[i] = ' & '
a = ''.join(x)
return a
def GetData(fd):
name = []
user = str(fd)
user = user[9:-3]
Auser = user.split("}>, <User: {")
for i in range(len(Auser)):
sALL = EDITstr(Auser[i])。
dic = sALL.split(",")
di = {}
for ii in range(len(dic)):
keys = dic[ii].split(":")
if ADDdict(keys):
di[keys[0]] = keys[1]
name.append(di)
return name
itchat.auto_login()
fd = itchat.get_friends(update=True)
FriendList = GetData(fd)
print(str(FriendList))
下一步是储存信息了。