feat: 添加多个功能模块和工具脚本
- 新增websocket客户端和服务端实现 - 添加图片压缩工具和快速压缩脚本 - 实现学生信息处理相关API - 添加MQTT客户端和消息处理功能 - 更新.gitignore忽略更多文件类型 - 添加数据库操作工具和示例 - 实现多个测试脚本和工具类
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import re
|
||||
|
||||
# 定义要处理的日志文件
|
||||
files = ["./info-2026-01-14.0.log","./info-2026-01-15.0.log","./info-2026-01-15.1.log"]
|
||||
|
||||
# 用于存储所有找到的唯一 empid
|
||||
unique_empids = set()
|
||||
|
||||
# 遍历每个文件
|
||||
for file_path in files:
|
||||
try:
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
# 使用正则表达式查找所有 "empid": "..." 模式的值
|
||||
# 匹配 "empid": "任何字符" 的模式
|
||||
matches = re.findall(r'"empid"\s*:\s*"([^"]*)"', content)
|
||||
unique_empids.update(matches) # 使用update方法添加到集合中,自动去重
|
||||
except FileNotFoundError:
|
||||
print(f"文件 {file_path} 不存在,跳过...")
|
||||
except Exception as e:
|
||||
print(f"读取文件 {file_path} 时出错: {e}")
|
||||
|
||||
# 将所有找到的唯一 empid 写入 ids.txt 文件
|
||||
with open('ids.txt', 'w', encoding='utf-8') as output_file:
|
||||
for empid in unique_empids:
|
||||
output_file.write(empid + '\n')
|
||||
|
||||
print(f"共找到 {len(unique_empids)} 个唯一的 empid,已写入 ids.txt 文件")
|
||||
if unique_empids:
|
||||
print("找到的唯一 empid 列表:")
|
||||
for empid in unique_empids:
|
||||
print(f" - {empid}")
|
||||
else:
|
||||
print("未找到任何 empid")
|
||||
Reference in New Issue
Block a user