标签:value open 有关 utf-8 odi style close oca 假设
#!/usr/bin/python3 # -*- coding: utf-8 -* import re # 定义日志文件 log_file = ‘/var/logs/test.log‘ f = open(log_file, ‘r+‘) lines = f.readlines() def print_log(): # 查找关键字 for line in lines: if "xiaoming" in line: line1 = line print(line1) # 查找value的值 if ‘location=xiaoming, value=‘ in line1: value = re.findall(r‘value=(\w+)*‘, line1, re.M) print(value) print_log() f.close()
标签:value open 有关 utf-8 odi style close oca 假设
原文地址:https://www.cnblogs.com/37yan/p/10710911.html