Before, I wrote this article, using Python to extract the speech time of all the members of the group, and made a simple analysis. First, add the acquisition of a message record for a particular individual group member (here, for example, a small white).
The code is relatively simple, mainly the writing of regular expressions. (Attached: The export of chat file records, please refer to the above mentioned article)
The code is as follows:
# ./9/ -#从QQ聊天数据导出特定人发言的日期时间和发言内容import reimport xlsxwriter# Small white Here's the nickname for the object you want to get data for. For convenience, see the file name of the data export is also clearly workbook= Xlsxwriter. Workbook ('little white. xlsx') Worksheet=Workbook.add_worksheet () worksheet.set_column ('a:a',5) Worksheet.set_column ('b:b',Ten) Worksheet.set_column ('C:c', $) with open ('advanced mathematics. TXT', encoding='Utf-8') asf:s=F.read () # Regular, matching pa across rows= Re.compile (r'^ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) Small white \ (small white QQ number \) \ n (. *?) \n$', Re. dotall+Re. MULTILINE) Ma=Re.findall (pa,s) # print (Len (MA)) forIinchRange (len (MA)): # Print (ma[i][0]) Date= ma[i][0] Time= ma[i][1] Word= ma[i][2] Worksheet.write (int(i),0, date) Worksheet.write (int(i),1, Time) Worksheet.write (int(i),2, Word) workbook.close () print ("go ahead and look at the new. xlsx file under the folder.")
Do something interesting with python-analyze QQ Chat history (Supplemental)