3.2.5.4 analysis blacklist and 3.2.5.4 blacklist
Assume that you are developing a mobile phone application, for example, obtaining a blacklist of phone numbers from the cloud center. However, these phone numbers are returned as a text file, we need to analyze these lines of text into telecom suppliers, telephone numbers, remarks, and tags. In fact, this process is to convert serialized information into structured information, this makes it easier to handle the problem. For example, you can use the phone number for comparison.
Example:
Text = "18701808546 1-digit user fraud number)
15396989999 harassment Number of one user)
15992460848 1-digit user fraud number)
15625759163 sales promotion and intermediary for one user)
15994768049 one user sent fraud information)
18670826757 1-digit user fraud number)
13141465810 1-digit user fraud number)
13860039526: 1-digit user fraud number )"""
Entries = re. split ("\ n +", text)
Print (entries)
L = [re. split (":? ", Entry, 2) for entry in entries]
Print (l)
Print ('\ n output phone number :')
For phone in l:
Print (phone [0])
The output is as follows:
['1st user fraud number (18701808546) ', '1st user harassment number (15396989999)', '1st user fraud number (15992460848 )', '2014, 1 user sales promotion, intermediary (15625759163) ', '2014, 1 user fraud information (15994768049)', '2014, 1 user fraud number (18670826757 )', '2017 1-digit user fraud number (13141465810) ', '2017: 1-digit user fraud number (13860039526)']
[['000000', '1-digit user fraud number', '(18701808546)'], ['000000', '1-digit user harassment number', '(15396989999) '], ['000000', '1-digit user fraud number',' () '], ['000000', '1-digit user sales promotion, intermediary ', '(15994768049)'], ['20140901', 'one-user fraud information', '(18670826757)'], ['20140901 ', '1-digit user fraud number', '(13141465810)'], ['123', '1-digit user fraud number', '(13860039526)'], ['123 ', '1-digit user fraud number', '()']
Output phone number:
18701808546
15396989999
15992460848
15625759163
15994768049
18670826757
13141465810
13860039526
In this example, re. split ("\ n +", text) to first remove multiple empty lines, so that all the text is close together, use [re. split (":? ", Entry, 2) for entry in entries] To split each line of text into available information formats and divide the text into three groups at most, finally, you can obtain the results of all phone numbers by traversing the list l, so that when there is a call display, you can determine whether the number is in these lists, if the phone is hung up, block all harassing calls, advertising calls, and improve the efficiency of society as a whole. Such annoying calls will interrupt you during work hours when you are just in bed, or it may cause a lot of problems when you drive.
Cai junsheng QQ: 9073204 Shenzhen
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.