#!/usr/bin/env python3
# coding: utf-8

from wxpy import *

'''
使用 cache 来缓存登陆信息，同时使用控制台登陆
'''
bot = Bot('bot.pkl', console_qr=False)


'''
开启 PUID 用于后续的控制
'''
bot.enable_puid('wxpy_puid.pkl')

friends = bot.friends()
groups = bot.groups()

output = open('data', 'w',encoding='UTF-8')

output.write("-----Friends-------\n")
for i in friends:
    output.write(i.nick_name + " ---> " + i.puid + "\n")
    pass

output.write("-----Groups-------\n")
for i in groups:
    output.write(i.name + " ---> " + i.puid + "\n")
    pass






@@ -238,16 +238,13 @@
 ()%0A%0A
-output =
+with 
  ope
@@ -274,18 +274,32 @@
 'UTF-8')
-%0A%0A
+ as output:%0A    
 output.w
@@ -320,32 +320,36 @@
 ends-------%5Cn%22)%0A
+    
 for i in friends
@@ -350,16 +350,20 @@
 riends:%0A
+    
     outp
@@ -403,32 +403,36 @@
  i.puid + %22%5Cn%22)%0A
+    
     pass%0A%0Aoutput
@@ -424,17 +424,25 @@
    pass%0A
-%0A
+    %0A    
 output.w
@@ -470,16 +470,20 @@
 ---%5Cn%22)%0A
+    
 for i in
@@ -491,24 +491,28 @@
 groups:%0A    
+ 
+   
 output.write
@@ -543,24 +543,28 @@
 uid + %22%5Cn%22)%0A
+    
     pass%0A%0A%0A%0A

use context manager for file open process