yigecook's recent timeline updates
yigecook

yigecook

V2EX member #241599, joined on 2017-07-20 03:25:27 +08:00
yigecook's recent replies
Oct 13, 2024
Replied to a topic by kongkongye 程序员 AI 成本太高怎么办?
找能付得起💰的甲方
Sep 6, 2024
Replied to a topic by maleclub Android 给一加宣布死刑
本来还想换安卓,看样子不如买其他地区的 iphone
3g 的话,用 python 操作流式处理,也不用每五分钟处理,设置 chunk 为 200M ,就好。

```python
import re

# 定义敏感数据的正则表达式模式
sensitive_data_pattern = re.compile(r'\b\d{16}\b')

def process_chunk(chunk):
# 使用正则表达式替换敏感数据
return sensitive_data_pattern.sub('****', chunk)

def process_log_file(input_file_path, output_file_path, chunk_size=200*1024*1024):
with open(input_file_path, 'rb') as input_file, open(output_file_path, 'wb') as output_file:
while True:
chunk = input_file.read(chunk_size)
if not chunk:
break
# 将字节数据转换为字符串进行处理
chunk_str = chunk.decode('utf-8', errors='ignore')
processed_chunk_str = process_chunk(chunk_str)
# 将处理后的字符串转换回字节数据
processed_chunk = processed_chunk_str.encode('utf-8')
output_file.write(processed_chunk)

# 使用示例
input_file_path = 'path/to/your/large_log_file.log'
output_file_path = 'path/to/your/processed_log_file.log'

process_log_file(input_file_path, output_file_path)
```

以上脚本的工作流程如下:

定义敏感数据的正则表达式模式,用于匹配和替换敏感数据。
process_chunk 函数会对读取的块进行处理,移除敏感数据。
process_log_file 函数会逐块读取输入日志文件,每次读取 200M 的数据,处理后写入到输出文件。
通过这种方式,处理过程不会占用超过 200M 的内存,同时也能够有效地移除日志中的敏感数据。请根据您的具体需求调整正则表达式模式和其他处理逻辑。
你的精力够同时应付几个项目?手动切一下很快呀
Sep 3, 2023
Replied to a topic by LisaSue iOS 请问 ios 可以把收到的短信转发到邮箱吗
可以的,我实现了从 iphone 转发到安卓
我也有同样 的问题
Dec 26, 2021
Replied to a topic by 7ms macOS Monterey 12.1 收不到更新
同样的问题,一直无法升级
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   945 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 19:43 · PVG 03:43 · LAX 12:43 · JFK 15:43
♥ Do have faith in what you're doing.