当前位置:首页>python>Python re模块:正则表达式实战指南,文本处理的瑞士军刀!

Python re模块:正则表达式实战指南,文本处理的瑞士军刀!

  • 2026-03-26 14:11:08
Python re模块:正则表达式实战指南,文本处理的瑞士军刀!
引言:为什么你的文本处理代码又长又难维护?
在日常Python开发中,你是否经常遇到以下痛点:
  • 数据提取困难:从混乱的日志文件、HTML页面或用户输入中提取特定信息时,手动切片和查找代码冗长且脆弱
  • 格式验证复杂:验证邮箱、手机号、URL等格式时,多层if-else嵌套让代码可读性急剧下降
  • 批量替换麻烦:需要根据复杂规则批量替换文本内容时,字符串方法难以应对多变的模式匹配需求
  • 性能瓶颈明显:处理大文本文件时,简单的循环匹配效率低下,内存占用高
如果你有这些困扰,那么re模块就是你的终极解决方案!作为Python标准库的正则表达式引擎,re模块提供了Perl风格的正则表达式支持,能够将复杂的文本匹配逻辑简化为一两行代码,同时在处理效率和表达能力上都有显著优势。
今天,我们将深入剖析re模块的核心功能,通过丰富的实战案例和代码示例,让你彻底掌握这个"文本处理的瑞士军刀"!
一、正则表达式基础概念
1.1 什么是正则表达式?
正则表达式(Regular Expression,简称Regex)是一种用于描述字符串模式的表达式语言。它使用特殊的语法规则,可以精确地定义要匹配的文本模式,包括:
  • 普通字符:字母、数字、汉字等直接匹配自身
  • 元字符:具有特殊含义的字符,如.*+?
  • 字符类:用方括号[]定义的字符集合
  • 量词:指定前面元素出现次数的符号
  • 边界匹配:匹配字符串的开始、结束或单词边界
  • 分组引用:用圆括号()创建的子表达式
1.2 为什么在Python中使用原始字符串?
在Python中定义正则表达式时,强烈建议使用原始字符串(raw string),即在字符串前加上r前缀:
# 推荐:使用原始字符串pattern = r'\d+\.\d+'# 匹配浮点数# 不推荐:普通字符串需要双重转义pattern = '\\d+\\.\\d+'# 同样的模式,但可读性差
使用原始字符串可以避免Python字符串转义与正则表达式转义之间的冲突,让模式更加清晰可读。
二、re模块核心函数详解
2.1 re.compile():预编译正则表达式
re.compile()函数将正则表达式字符串编译成Pattern对象,供后续重复使用,能显著提升性能。
import re# 未编译:每次调用都会重新编译正则表达式for i in range(1000):    matches = re.findall(r'\d+'f'文本{i}')# 已编译:只需编译一次,后续高效复用pattern = re.compile(r'\d+')  # 编译成正则表达式对象for i in range(1000):    matches = pattern.findall(f'文本{i}')
性能对比:在处理1000次匹配时,预编译可以提升30%-50%的性能,尤其适合高频使用的复杂模式。
2.2 re.match():从字符串开头匹配
re.match()只从字符串的起始位置开始匹配,如果起始位置不匹配,则立即返回None
import re# 匹配成功:起始位置符合模式match_result = re.match(r'hello''hello world')if match_result:    print(f"匹配成功: {match_result.group()}")  # 输出: helloelse:    print("匹配失败")# 匹配失败:起始位置不符合模式match_result = re.match(r'world''hello world')print(match_result)  # 输出: None# 实际应用:验证URL协议url = 'https://example.com'if re.match(r'^https?://', url):    print("有效的HTTP/HTTPS URL")else:    print("无效的URL协议")
适用场景:验证前缀、协议检查、固定格式验证。
2.3 re.search():搜索整个字符串
re.search()在整个字符串中搜索第一个匹配项,不限于起始位置。
import re# 在任意位置搜索text = "商品价格: ¥299.99,折扣价: ¥249.99"search_result = re.search(r'\d+\.\d+', text)if search_result:    print(f"找到价格: {search_result.group()}")  # 输出: 299.99    print(f"位置: {search_result.span()}")      # 输出: (6, 12)# 查找首次出现的邮箱email_text = "联系我们: support@example.com 或 sales@company.org"email_match = re.search(r'[\w\.-]+@[\w\.-]+\.\w+', email_text)if email_match:    print(f"找到邮箱: {email_match.group()}")  # 输出: support@example.com
与match的区别match只检查起始位置,search搜索整个字符串。
2.4 re.findall():返回所有匹配项的列表
re.findall()返回字符串中所有非重叠匹配的列表,是最常用的提取函数。
import re# 提取所有数字text = "订单号: 12345, 金额: ¥599.00, 数量: 3"numbers = re.findall(r'\d+', text)print(f"所有数字: {numbers}")  # 输出: ['12345', '599', '00', '3']# 提取所有日期date_text = "事件: 2023-08-15, 会议: 2024-12-01, 截止: 2025-02-28"dates = re.findall(r'\d{4}-\d{2}-\d{2}', date_text)print(f"所有日期: {dates}")  # 输出: ['2023-08-15', '2024-12-01', '2025-02-28']# 分组提取:返回元组列表contact_text = "姓名: 张三, 电话: 13800138000; 姓名: 李四, 电话: 13900139000"contacts = re.findall(r'姓名: (\w+), 电话: (\d{11})', contact_text)print(f"联系人信息: {contacts}")  # 输出: [('张三', '13800138000'), ('李四', '13900139000')]
注意:当模式中有分组时,findall()返回分组内容的元组列表,而非整个匹配。
2.5 re.finditer():返回匹配对象的迭代器
re.finditer()返回一个迭代器,逐个生成Match对象,适合处理大文本。
import re# 迭代处理大文本text = "错误1: 网络超时; 错误2: 文件未找到; 错误3: 权限不足"error_iter = re.finditer(r'错误\d+: (\w+)', text)print("所有错误详情:")for match in error_iter:    error_num = match.group(0)     # 整个匹配,如"错误1: 网络超时"    error_desc = match.group(1)    # 第一个分组,如"网络超时"    start_pos, end_pos = match.span()    print(f"  {error_num} - {error_desc} (位置: {start_pos}-{end_pos})")# 输出:# 所有错误详情:#   错误1: 网络超时 - 网络超时 (位置: 0-8)#   错误2: 文件未找到 - 文件未找到 (位置: 10-19)#   错误3: 权限不足 - 权限不足 (位置: 21-28)
内存优势:对于超大文本,finditer()可以流式处理,避免一次性加载所有匹配到内存。
2.6 re.sub():替换匹配内容
re.sub()将字符串中所有匹配模式的部分替换为指定内容。
import re# 基础替换:隐藏手机号中间四位text = "用户电话: 13800138000, 客服: 13912345678"protected_text = re.sub(r'(\d{3})\d{4}(\d{4})'r'\1****\2', text)print(f"脱敏后: {protected_text}")# 输出: 用户电话: 138****8000, 客服: 139****5678# 函数替换:动态生成替换内容defto_upper(match):"""将匹配的单词转为大写"""return match.group().upper()text = "python is awesome! learn python today."result = re.sub(r'\b\w+\b', to_upper, text)print(f"大写后: {result}")  # 输出: PYTHON IS AWESOME! LEARN PYTHON TODAY.# 复杂替换:格式化日期dates_text = "2023/08/15, 2024-12-01, 2025.02.28"standardized = re.sub(r'(\d{4})[/.-](\d{2})[/.-](\d{2})'r'\1-\2-\3', dates_text)print(f"标准化日期: {standardized}")  # 输出: 2023-08-15, 2024-12-01, 2025-02-28
高级技巧re.sub()的替换参数可以是字符串(支持分组引用\1\2等)或函数(动态生成替换内容)。
2.7 re.split():基于正则表达式分割字符串
re.split()按照模式匹配处分割字符串,比str.split()更灵活。
import re# 复杂分隔符:逗号、空格、分号任意组合text = "apple, banana  orange;grape; mango"parts = re.split(r'[,\s;]+', text)print(f"分割结果: {parts}")  # 输出: ['apple', 'banana', 'orange', 'grape', 'mango']# 保留分隔符:使用捕获分组text = "10+20-30*40/50"parts = re.split(r'([+\-*/])', text)print(f"带运算符的分割: {parts}")  # 输出: ['10', '+', '20', '-', '30', '*', '40', '/', '50']# 多字符分隔符text = "Python::Java::C++::JavaScript"languages = re.split(r'::', text)print(f"编程语言: {languages}")  # 输出: ['Python', 'Java', 'C++', 'JavaScript']
适用场景:处理不规则分隔符、复杂文本解析、日志分析。
三、模式语法详解
3.1 字符类:精确匹配字符集合
模式
含义
示例
匹配结果
[abc]
匹配a、b或c
r'[aeiou]'
"hello" → ['e', 'o']
[a-z]
匹配小写字母
r'[a-z]+'
"Python3" → ['ython']
[^abc]
匹配除a、b、c外的字符
r'[^0-9]'
"123abc" → ['a', 'b', 'c']
\d
匹配数字
r'\d+'
"ID: 12345" → ['12345']
\w
匹配单词字符(字母、数字、下划线)
r'\w+'
"user_name123" → ['user_name123']
\s
匹配空白字符
r'\s+'
"a b c" → [' ', ' ']
3.2 量词:控制匹配次数
模式
含义
贪婪?
示例
匹配结果
*
0次或多次
贪婪
r'a*'
"aaa" → ['aaa']
+
1次或多次
贪婪
r'a+'
"aaa" → ['aaa']
?
0次或1次
贪婪
r'a?'
"aaa" → ['a', 'a', 'a']
{n}
恰好n次
贪婪
r'a{3}'
"aaa" → ['aaa']
{n,}
n次或更多
贪婪
r'a{2,}'
"aaa" → ['aaa']
{n,m}
n到m次
贪婪
r'a{1,3}'
"aaa" → ['aaa']
*?
0次或多次
非贪婪
r'a*?'
"aaa" → ['', '', '', '']
+?
1次或多次
非贪婪
r'a+?'
"aaa" → ['a', 'a', 'a']
贪婪与非贪婪对比
import retext = "<div>内容1</div><div>内容2</div>"# 贪婪匹配:匹配尽可能多的字符greedy_match = re.findall(r'<div>.*</div>', text)print(f"贪婪匹配: {greedy_match}")  # 输出: ['<div>内容1</div><div>内容2</div>']# 非贪婪匹配:匹配尽可能少的字符non_greedy_match = re.findall(r'<div>.*?</div>', text)print(f"非贪婪匹配: {non_greedy_match}")  # 输出: ['<div>内容1</div>', '<div>内容2</div>']
3.3 分组与捕获:提取子匹配
import re# 基础分组:提取区号和号码phone = "电话: (010) 1234-5678"match = re.search(r'<inline_LaTeX_Formula>(\d{3})<\inline_LaTeX_Formula>\s*(\d{4})-(\d{4})', phone)if match:    print(f"整个匹配: {match.group(0)}")  # 输出: (010) 1234-5678    print(f"区号: {match.group(1)}")      # 输出: 010    print(f"号码前四位: {match.group(2)}")  # 输出: 1234    print(f"号码后四位: {match.group(3)}")  # 输出: 5678    print(f"所有分组: {match.groups()}")   # 输出: ('010', '1234', '5678')# 命名分组:提高代码可读性log_line = '192.168.1.1 - - [10/Oct/2023:13:55:36] "GET /index.html HTTP/1.1" 200 1024'pattern = r'(?P<ip>\d+\.\d+\.\d+\.\d+).*?"(?P<method>\w+) (?P<url>[^\s]+) HTTP'match = re.match(pattern, log_line)if match:    print(f"IP地址: {match.group('ip')}")      # 输出: 192.168.1.1    print(f"请求方法: {match.group('method')}"# 输出: GET    print(f"请求路径: {match.group('url')}")   # 输出: /index.html    print(f"字典形式: {match.groupdict()}")    # 输出: {'ip': '192.168.1.1', 'method': 'GET', 'url': '/index.html'}
3.4 断言:零宽度位置匹配
import re# 正向前瞻:匹配后面跟着"美元"的数字text = "价格: 100美元, 200人民币, 300美元"usd_prices = re.findall(r'\d+(?=美元)', text)print(f"美元价格: {usd_prices}")  # 输出: ['100', '300']# 负向前瞻:匹配后面不跟着"人民币"的数字non_cny_prices = re.findall(r'\d+(?!人民币)', text)print(f"非人民币价格: {non_cny_prices}")  # 输出: ['100', '20', '300']# 正向后顾:匹配前面是"$"的数字text2 = "报价: $150, ¥200, $300"dollar_prices = re.findall(r'(?<=\$)\d+', text2)print(f"美元报价: {dollar_prices}")  # 输出: ['150', '300']
四、实战应用场景
4.1 文本提取:从日志中结构化数据
import refrom collections import defaultdictdefparse_nginx_log(log_lines):"""解析Nginx访问日志,提取结构化数据"""# 编译高效的正则模式(使用命名分组提高可读性)    pattern = re.compile(r'(?P<ip>\d+\.\d+\.\d+\.\d+)\s-\s-\s'# IP地址r'\[(?P<datetime>[^\]]+)\]\s'# 时间戳r'"(?P<method>\w+)\s(?P<url>[^\s]+)\s[^"]+"\s'# 请求行r'(?P<status>\d{3})\s(?P<size>\d+)'# 状态码和大小    )    stats = {'total_requests'0,'status_codes': defaultdict(int),'top_ips': defaultdict(int),'methods': defaultdict(int)    }for line in log_lines:        match = pattern.search(line)ifnot match:continue        info = match.groupdict()        stats['total_requests'] += 1        stats['status_codes'][info['status']] += 1        stats['top_ips'][info['ip']] += 1        stats['methods'][info['method']] += 1return stats# 示例日志数据sample_logs = ['192.168.1.1 - - [10/Oct/2023:13:55:36 +0800] "GET /index.html HTTP/1.1" 200 1024','192.168.1.2 - - [10/Oct/2023:13:55:37 +0800] "POST /api/login HTTP/1.1" 401 512','192.168.1.1 - - [10/Oct/2023:13:55:38 +0800] "GET /static/css/style.css HTTP/1.1" 200 2048',]# 执行解析results = parse_nginx_log(sample_logs)print(f"总请求数: {results['total_requests']}")print(f"状态码分布: {dict(results['status_codes'])}")print(f"IP访问统计: {dict(results['top_ips'])}")print(f"请求方法统计: {dict(results['methods'])}")
4.2 数据清洗:标准化金融数据
import redefclean_financial_data(text):"""清洗金融数据文本,提取标准化信息"""    result = {'amounts': [],'dates': [],'percentages': [],'cleaned_text': text    }# 提取金额(支持千分位分隔符)    amount_pattern = r'\$?\s*\d{1,3}(?:,\d{3})*(?:\.\d{2})?'    amounts = re.findall(amount_pattern, text)    result['amounts'] = [re.sub(r'[^\d.]''', amt) for amt in amounts]# 提取日期(支持多种格式)    date_pattern = r'\b\d{4}[-./]\d{1,2}[-./]\d{1,2}\b'    dates = re.findall(date_pattern, text)# 标准化为YYYY-MM-DD格式    result['dates'] = []for date in dates:# 统一分隔符为短横线        normalized = re.sub(r'[-./]''-', date)# 补零:确保月和日都是两位数        parts = normalized.split('-')if len(parts) == 3:            year, month, day = parts            month = month.zfill(2)            day = day.zfill(2)            result['dates'].append(f'{year}-{month}-{day}')# 提取百分比    percent_pattern = r'(\d{1,3}(?:\.\d+)?)%'    percents = re.findall(percent_pattern, text)    result['percentages'] = [str(float(p)/100for p in percents]# 清洗原始文本(移除多余空格、特殊字符)    cleaned = re.sub(r'\s+'' ', text)  # 多个空格合并为一个    cleaned = re.sub(r'[^\w\s.,$%()-]''', cleaned)  # 保留基本字符    result['cleaned_text'] = cleaned.strip()return result# 示例金融文本financial_text = """2023年Q4财报显示: 总收入: $1,250,750.50,同比增长 15.5%净收入: ¥850,300.00,环比增长 8.2%报告日期: 2023/12/31, 发布日期: 2024-1-15"""# 执行清洗cleaned_data = clean_financial_data(financial_text)print(f"提取的金额: {cleaned_data['amounts']}")print(f"提取的日期: {cleaned_data['dates']}")print(f"提取的百分比: {cleaned_data['percentages']}")print(f"清洗后的文本: {cleaned_data['cleaned_text']}")
4.3 表单验证:安全可靠的输入检查
import reclassFormValidator:"""表单验证器,使用正则表达式进行输入验证"""def__init__(self):# 编译常用验证模式(提高性能)        self.patterns = {'email': re.compile(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'            ),'phone_cn': re.compile(r'^1[3-9]\d{9}$'# 中国大陆手机号            ),'password': re.compile(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$'            ),'username': re.compile(r'^[a-zA-Z0-9_-]{3,20}$'# 3-20位字母数字下划线短横线            ),'url': re.compile(r'^https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+[/\w.-]*\??[\w=&%-]*$'            ),'ipv4': re.compile(r'^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}'r'(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'            )        }defvalidate(self, field_type, value):"""验证指定类型的字段值"""if field_type notin self.patterns:raise ValueError(f"不支持的字段类型: {field_type}")        pattern = self.patterns[field_type]return bool(pattern.fullmatch(value))  # 使用fullmatch确保整个字符串匹配defextract_emails(self, text):"""从文本中提取所有邮箱地址"""return self.patterns['email'].findall(text)defsanitize_html(self, html):"""简单HTML标签清理(防止XSS攻击)"""# 只允许安全的HTML标签和属性        safe_html = re.sub(r'<script\b[^>]*>(.*?)</script>''', html, flags=re.IGNORECASE)        safe_html = re.sub(r'on\w+="[^"]*"''', safe_html)  # 移除事件处理器return safe_html# 使用示例validator = FormValidator()# 邮箱验证test_emails = ["user@example.com",      # 有效"invalid.email@com",     # 无效(顶级域名太短)"name@domain.co.uk",     # 有效"admin@localhost",       # 无效(缺少顶级域名)]print("邮箱验证结果:")for email in test_emails:    is_valid = validator.validate('email', email)    print(f"  {email}{'✅ 有效'if is_valid else'❌ 无效'}")# 提取文本中的邮箱sample_text = "联系我们: support@company.com 或 sales@example.org"emails_found = validator.extract_emails(sample_text)print(f"提取到的邮箱: {emails_found}")
五、性能优化与最佳实践
5.1 避免灾难性回溯
import reimport time# 危险:嵌套贪婪量词导致指数级回溯dangerous_pattern = r'(a+)+b'# 安全:使用原子组避免回溯safe_pattern = r'(?>a+)+b'# 测试性能差异test_string = 'a' * 30 + 'c'# 故意不匹配bprint("性能对比测试:")start = time.time()try:    re.match(dangerous_pattern, test_string)except Exception as e:    print(f"危险模式异常: {e}")print(f"危险模式耗时: {time.time() - start:.4f}秒")start = time.time()re.match(safe_pattern, test_string)print(f"安全模式耗时: {time.time() - start:.4f}秒")
5.2 高效匹配策略
import re# 策略1:缩小匹配范围text = "订单号: ABC-2023-12345-001, 金额: ¥599.00"# 低效:在整个文本中搜索inefficient = re.search(r'\d{5}', text)# 高效:先定位到订单号区域order_section = re.search(r'订单号:\s*(.*?),', text)if order_section:    efficient = re.search(r'\d{5}', order_section.group(1))    print(f"高效匹配结果: {efficient.group() if efficient else'无'}")# 策略2:使用非捕获分组提升性能# 当不需要提取分组内容时,使用(?:...)代替()text = "颜色: red, green, blue"# 捕获分组(存储开销)capture_result = re.findall(r'(red|green|blue)', text)# 非捕获分组(无存储开销)non_capture_result = re.findall(r'(?:red|green|blue)', text)
5.3 编译标志使用技巧
import re# 使用VERBOSE模式提高复杂模式的可读性complex_pattern = re.compile(r"""    ^                       # 字符串开始    (?P<username>\w+)       # 用户名(字母数字下划线)    @                       # @符号    (?P<domain>             # 域名部分        [\w.-]+             # 子域名        \.                  # 点        [a-zA-Z]{2,}        # 顶级域名(至少2个字母)    )    $                       # 字符串结束""", re.VERBOSE)# 多标志组合使用multi_flags_pattern = re.compile(r"""    ^hello\s+world          # 匹配hello world    .*                      # 任意字符(包括换行)    end$                    # 以end结束""", re.VERBOSE | re.DOTALL | re.IGNORECASE)
六、常见问题与解决方案
6.1 匹配不到预期结果
问题:正则表达式看起来正确,但匹配不到结果。
解决方案
  1. 检查特殊字符转义:.*+?()[]等需要转义
  2. 确认匹配模式:使用match()还是search()
  3. 调试模式:使用re.DEBUG标志查看编译详情
import re# 调试模式示例pattern = re.compile(r'\d+\.\d+', re.DEBUG)
6.2 匹配结果包含多余内容
问题:匹配结果包含了不想要的内容。
解决方案
  1. 使用非贪婪量词:*?+???
  2. 精确限定匹配边界:使用^$\b
  3. 使用分组提取:只取需要的分组内容
import retext = "<div>内容1</div><div>内容2</div>"# 问题:匹配整个字符串problem = re.findall(r'<div>.*</div>', text)# 解决:使用非贪婪模式solution = re.findall(r'<div>.*?</div>', text)
6.3 性能问题
问题:正则表达式处理大文本时速度慢。
解决方案
  1. 预编译模式:使用re.compile()
  2. 避免回溯爆炸:谨慎使用嵌套量词
  3. 分层处理:先粗筛再精匹配
七、总结与扩展学习资源
7.1 核心要点回顾
  1. re.compile()是关键:预编译正则表达式显著提升重复使用性能
  2. 理解函数差异match()search()findall()finditer()各有适用场景
  3. 掌握模式语法:字符类、量词、分组、断言是构建复杂模式的基础
  4. 重视性能优化:避免灾难性回溯,合理使用编译标志
  5. 实战导向:将正则表达式应用到日志分析、数据清洗、表单验证等实际场景
7.2 扩展学习建议
  1. 深入学习正则表达式引擎原理:理解NFA/DFA差异,掌握回溯机制
  2. 探索第三方库regex库提供更强大的功能和更好的性能
  3. 集成其他工具:结合pandas进行数据框处理,结合BeautifulSoup进行HTML解析
  4. 实践项目驱动:在实际项目中应用正则表达式,积累经验
7.3 推荐资源
  1. 官方文档Python re模块文档
  2. 在线测试工具Regex101 - 支持Python语法,提供详细解释
  3. 经典书籍:《精通正则表达式》(第3版)- 深入理解正则表达式原理
  4. 实战教程Real Python正则表达式指南

今日收获:通过本篇文章,你已经掌握了Python re模块的核心功能和使用技巧。正则表达式作为文本处理的强大工具,将在你的日常开发中发挥重要作用。记住:实践是最好的老师,多在实际项目中应用这些知识,你会越来越熟练!
下期预告:明天我们将探索Python os模块,学习如何优雅地与操作系统交互,管理文件和进程。敬请期待!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 09:55:30 HTTP/2.0 GET : https://f.mffb.com.cn/a/483020.html
  2. 运行时间 : 0.138733s [ 吞吐率:7.21req/s ] 内存消耗:4,756.98kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=f9d06ca23124cd70e394d055ad00b266
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.001005s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001730s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000777s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000688s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001566s ]
  6. SELECT * FROM `set` [ RunTime:0.000637s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001545s ]
  8. SELECT * FROM `article` WHERE `id` = 483020 LIMIT 1 [ RunTime:0.001185s ]
  9. UPDATE `article` SET `lasttime` = 1774576530 WHERE `id` = 483020 [ RunTime:0.025578s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000749s ]
  11. SELECT * FROM `article` WHERE `id` < 483020 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001182s ]
  12. SELECT * FROM `article` WHERE `id` > 483020 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001185s ]
  13. SELECT * FROM `article` WHERE `id` < 483020 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001968s ]
  14. SELECT * FROM `article` WHERE `id` < 483020 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002356s ]
  15. SELECT * FROM `article` WHERE `id` < 483020 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.003971s ]
0.142518s