This article example describes how Python counts the number of uuids in a file after de-duplication. Shared for your reference. Specific as follows:
Get the uuids in the log file by line using regular expressions and count the number of de-duplicates of these uuids (de-duplicates using set).
import re pattern=(r'&uuid=.*&') uuidset=set() with open('.2015-05-26','rt') as f: for line in f: all=(line) if len(all)>0 and ('iphone')>0: # print(all[0]) (all[0]) print(len(uuidset))
I hope that what I have described in this article will help you in your Python programming.