Python统计文件中去重后uuid个数的方法
作者:mikeszhang 时间:2023-07-11 17:20:06
本文实例讲述了Python统计文件中去重后uuid个数的方法。分享给大家供大家参考。具体如下:
利用正则表达式按行获取日志文件中的的uuid,并且统计这些uuid的去重个数(去重利用set)
import re
pattern=re.compile(r'&uuid=.*&')
uuidset=set()
with open('request.log.2015-05-26','rt') as f:
for line in f:
all=pattern.findall(line)
if len(all)>0 and line.find('iphone')>0:
# print(all[0])
uuidset.add(all[0])
print(len(uuidset))
希望本文所述对大家的Python程序设计有所帮助。
标签:Python,统计
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实现图片格式转换
2023-08-03 04:58:57
![](https://img.aspxhome.com/file/2023/7/60967_0s.jpg)
SQL Server使用T-SQL进阶之公用表表达式(CTE)
2024-01-17 22:42:32
![](https://img.aspxhome.com/file/2023/8/89698_0s.jpg)
MySQL在线开启或禁用GTID模式
2024-01-24 01:13:52
![](https://img.aspxhome.com/file/2023/9/105659_0s.jpg)
Python创建一个空的dataframe,并循环赋值的方法
2022-03-09 22:25:41
MySQL中IF()、IFNULL()、NULLIF()、ISNULL()函数的使用详解
2024-01-17 17:53:34
Python实现TOPSIS分析法的示例代码
2021-05-09 19:32:47
![](https://img.aspxhome.com/file/2023/1/109621_0s.png)
go 对象池化组件 bytebufferpool使用详解
2024-02-10 14:26:11
栈和队列数据结构的基本概念及其相关的Python实现
2022-03-14 23:18:28
Vue自定义可以选择日期区间段的日历插件
2024-05-11 09:11:19
![](https://img.aspxhome.com/file/2023/5/126535_0s.jpg)
Python xml、字典、json、类四种数据类型如何实现互相转换
2023-10-17 17:36:20
tkinter自定义下拉多选框问题
2022-09-27 06:40:00
![](https://img.aspxhome.com/file/2023/2/107862_0s.png)
Python入门学习指南分享
2023-09-02 15:02:21
![](https://img.aspxhome.com/file/2023/1/124681_0s.png)
Python机器学习入门(三)之Python数据准备
2021-05-27 19:49:42
关于Python中的if __name__ == __main__详情
2022-05-04 10:16:28
![](https://img.aspxhome.com/file/2023/2/127322_0s.png)
python实现将json多行数据传入到mysql中使用
2022-12-28 06:41:51
MySQL慢查日志的开启方式与存储格式详析
2024-01-12 14:21:47
![](https://img.aspxhome.com/file/2023/8/75638_0s.png)
解决pycharm上的jupyter notebook端口被占用问题
2022-10-28 15:43:13
![](https://img.aspxhome.com/file/2023/6/115426_0s.jpg)
用Python实现KNN分类算法
2021-12-26 14:15:24
![](https://img.aspxhome.com/file/2023/2/71332_0s.jpg)
Mysql数据库中的redo log 写入策略和binlog 写入策略
2024-01-27 08:21:14
JavaScript省市级联下拉菜单实例
2024-04-10 16:18:18