当前位置:首页>python>第349讲:VBA调用Python脚本(混合编程)

第349讲:VBA调用Python脚本(混合编程)

  • 2026-08-18 23:12:07
第349讲:VBA调用Python脚本(混合编程)

场景:VBA负责UI交互和Excel操作,Python负责复杂数据建模

一、为什么要把VBA和Python混在一起用?

很多Excel重度用户都有这样的困扰:VBA操作Excel确实方便,拖个按钮、弹个对话框、读写单元格,几行代码就搞定。但一旦涉及复杂的数据处理——比如时间序列预测、机器学习建模、大规模文本分析——VBA就力不从心了。

反过来,Python干这些事是强项,但Python操作Excel的体验远不如VBA丝滑,尤其是要做交互式界面的时候。

所以思路很自然:各干各擅长的事。 VBA管前端(按钮、表单、单元格读写),Python管后端(算法、建模、计算),两者之间通过某种方式"对话"就行。

这就是混合编程的核心逻辑。


二、三种主流调用方式概览

方式

原理

优点

缺点

适用场景

Shell调用

VBA用Shell执行python.exe

零依赖,最简单

参数传递麻烦,无返回值

简单脚本、批处理

xlwings

Python库,VBA端有插件

双向通信,体验最好

需安装xlwings

深度集成项目

文件交换

读写中间文件(CSV/JSON)

解耦彻底

IO开销,不够实时

大数据量、离线计算

下面逐一展开。


三、方法一:Shell调用Python脚本

3.1 Python端:编写可接收参数的独立脚本

核心思路:Python脚本从命令行接收参数,处理完后把结果输出到标准输出(stdout),VBA读取这个输出。

# model_predict.pyimport sysimport jsonimport argparsedef predict(data_list):    """    模拟一个"复杂模型"    实际场景可能是:ARIMA预测、随机森林分类、NLP情感分析等    """    # 这里用简单加权求和模拟模型输出    result = sum(data_list) * 1.15    return round(result, 4)if __name__ == "__main__":    # 方式1:通过argparse接收参数    parser = argparse.ArgumentParser(description='Excel数据预测模型')    parser.add_argument('--data'type=strhelp='JSON格式的输入数据')    args = parser.parse_args()    try:        data = json.loads(args.data)        prediction = predict(data)        # 输出结果(VBA会捕获这个输出)        print(json.dumps({"status""success""result": prediction}))    except Exception as e:        print(json.dumps({"status""error""message"str(e)}))

3.2 VBA端:Shell调用并获取输出

VBA的Shell函数本身不能直接捕获输出,需要借助WScript.Shell

' 模块:modPythonCallerFunction CallPythonScript(scriptPath As String, jsonData As String) As String    Dim wsh As Object    Dim cmd As String    Dim exec As Object    Dim output As String    Set wsh = CreateObject("WScript.Shell")    ' 构造命令:python 脚本路径 --data "JSON数据"    cmd = "python """ & scriptPath & """ --data """ & jsonData & """"    ' 执行并捕获输出    Set exec = wsh.Exec(cmd)    ' 读取标准输出    Do While exec.Status = 0        DoEvents    Loop    output = exec.StdOut.ReadAll    CallPythonScript = outputEnd FunctionSub RunPrediction()    Dim result As String    Dim scriptPath As String    Dim inputData As String    scriptPath = ThisWorkbook.Path & "\model_predict.py"    ' 模拟从Excel读取数据    inputData = "[100, 120, 110, 130, 125]"    result = CallPythonScript(scriptPath, inputData)    ' 解析结果并写入单元格    Dim parsed As Object    Set parsed = JsonConverter.ParseJson(result)    If parsed("status") = "success" Then        Range("B10").Value = parsed("result")        MsgBox "预测完成!结果:" & parsed("result"), vbInformation    Else        MsgBox "预测失败:" & parsed("message"), vbCritical    End IfEnd Sub

注意:VBA中解析JSON需要引用Microsoft Scripting Runtime或使用第三方JSON解析库(如VBA-JSON)。

3.3 这种方式的坑

  1. 路径中有空格:python.exe路径或脚本路径含空格时,引号要处理好

  2. 等待执行完成:Shell是异步的,需要用循环等待进程结束

  3. 错误捕获:Python报错时信息在Stderr里,VBA端也要读取


四、方法二:xlwings实现深度集成

xlwings是目前VBA+Python混合编程最成熟的方案。它的核心优势是:Python可以直接读写Excel对象,VBA可以调用Python函数就像调用本地函数一样。

4.1 环境准备

pip install xlwings

在Excel中安装xlwings插件(只需一次):

xlwings addin install

4.2 Python端:定义可被VBA调用的函数

# excel_model.pyimport xlwings as xwimport numpy as npfrom sklearn.linear_model import LinearRegression@xw.funcdef predict_sales(periods):    """    预测未来N期销售额    VBA可以直接调用这个函数    """    # 从Excel读取历史数据    wb = xw.Book.caller()    sheet = wb.sheets['历史数据']    # 假设A列是期数,B列是销售额    history = sheet.range('B2:B100').value    history = [x for x in history if x is not None]    # 构建特征矩阵    X = np.arange(len(history)).reshape(-11)    y = np.array(history)    # 训练模型    model = LinearRegression()    model.fit(X, y)    # 预测未来    future_X = np.arange(len(history), len(history) + periods).reshape(-11)    predictions = model.predict(future_X)    return predictions.tolist()@xw.subdef run_full_analysis():    """    完整的分析流程(无返回值,作为宏调用)    """    wb = xw.Book.caller()    # 1. 数据清洗    raw_sheet = wb.sheets['原始数据']    clean_sheet = wb.sheets['清洗后']    data = raw_sheet.range('A1').expand().value    # ... 清洗逻辑 ...    # 2. 建模    # ... 复杂计算 ...    # 3. 写回结果    result_sheet = wb.sheets['结果']    result_sheet.range('A1').value = "分析完成"

4.3 VBA端:调用Python函数

xlwings安装后,Excel中会多出一个"xlwings"选项卡,同时VBA里可以直接用RunPython

Sub 调用Python预测()    ' 直接调用Python函数    RunPython "import excel_model; excel_model.predict_sales(12)"End SubSub 运行完整分析()    RunPython "import excel_model; excel_model.run_full_analysis()"End Sub

4.4 xlwings的两种模式

模式

说明

适用场景

User Defined Functions (UDF)

Python函数出现在Excel公式里

需要像普通函数一样拖拽使用

RunPython

VBA调用Python脚本

按钮触发、复杂流程

UDF示例,Python端加装饰器:

@xw.funcdef moving_average(data, window):    """移动平均,可直接在Excel单元格里用 =moving_average(A1:A10, 3)"""    import pandas as pd    s = pd.Series(data)    return s.rolling(window=window).mean().tolist()

五、方法三:文件交换(CSV/JSON桥接)

当数据量很大,或者Python脚本是独立部署的服务时,文件交换是最稳妥的方式。

5.1 VBA写CSV → Python读 → Python写结果 → VBA读

# batch_processor.pyimport pandas as pdimport sysdef process_excel_data(input_csv, output_csv):    df = pd.read_csv(input_csv)    # 复杂处理逻辑    df['score'] = df['value'] * df['weight'] / df['value'].sum()    df['rank'] = df['score'].rank(ascending=False)    df.to_csv(output_csv, index=False)    print(f"处理完成,结果写入{output_csv}")if __name__ == "__main__":    process_excel_data(sys.argv[1], sys.argv[2])

VBA端:

Sub 文件桥接调用()    Dim pythonScript As String    Dim inputFile As String    Dim outputFile As String    inputFile = ThisWorkbook.Path & "\input.csv"    outputFile = ThisWorkbook.Path & "\output.csv"    pythonScript = ThisWorkbook.Path & "\batch_processor.py"    ' 先把Excel数据导出为CSV    Range("A1:C100").Copy    ' ... 写入CSV文件 ...    ' 调用Python    Shell "python " & pythonScript & " " & inputFile & " " & outputFile, vbNormalFocus    ' 等待完成后读取结果    ' ... 读取CSV写回Excel ...End Sub

六、对比教学:同一个功能,Python vs VBA怎么写?

为了让你更直观地理解"为什么复杂逻辑交给Python",我们来看一个实际案例:计算一组数据的移动平均并标记异常值

6.1 VBA实现

Sub VBA_MovingAverage()    Dim data() As Double    Dim i As Long, j As Long    Dim window As Long    Dim sum As Double    window = 5    ' 假设数据在A列,从第2行开始    lastRow = Cells(Rows.Count, 1).End(xlUp).Row    ReDim data(1 To lastRow - 1)    For i = 1 To lastRow - 1        data(i) = Cells(i + 1, 1).Value    Next i    ' 计算移动平均    For i = window To UBound(data)        sum = 0        For j = i - window + 1 To i            sum = sum + data(j)        Next j        Cells(i + 12).Value = sum / window    Next i    ' 标记异常值(超过2倍标准差)    Dim mean As Double, stdDev As Double    ' ... 又是一堆循环计算均值和标准差 ...End Sub

6.2 Python实现(同一功能)

import pandas as pdimport numpy as npdef analyze_data(data_list, window=5):    df = pd.Series(data_list)    # 移动平均    ma = df.rolling(window=window).mean()    # 异常值标记(Z-score方法)    z_scores = np.abs((df - df.mean()) / df.std())    outliers = z_scores > 2    return {        'moving_average': ma.tolist(),        'outliers': outliers.tolist(),        'outlier_indices': np.where(outliers)[0].tolist()    }

6.3 对比总结

维度

VBA

Python

代码行数

~30行

~10行

可读性

循环嵌套,需要仔细读

链式调用,一眼看懂

扩展性

改逻辑要重写

换算法只需改一行

性能

小数据OK

大数据碾压

生态

几乎为零

pandas/sklearn/statsmodels随便挑

结论:VBA写业务逻辑和界面交互没问题,但涉及数据处理和建模,Python的效率是数量级的差距。


七、实战:完整混合编程案例

场景:销售数据预测仪表板

架构设计

┌─────────────────────────────────────┐
│         Excel 前端(VBA)            │
│  ┌─────────┐  ┌──────────────────┐ │
│  │ 按钮控件 │  │  数据输入表单     │ │
│  └────┬────┘  └──────────────────┘ │
│       │                             │
│       ▼                             │
│  ┌────────────────┐                 │
│  │ RunPython调用   │◄─── xlwings ──┤
│  └───────┬────────┘                 │
└──────────┼──────────────────────────┘
           │
           ▼
┌──────────────────────────────────────┐
│      Python 后端                      │
│  ┌──────────┐  ┌──────────────────┐ │
│  │ 数据预处理 │  │  预测模型训练     │ │
│  └──────────┘  └──────────────────┘ │
│       │                    │        │
│       ▼                    ▼        │
│  ┌──────────────────────────────┐   │
│  │  结果写回Excel                │   │
│  └──────────────────────────────┘   │
└──────────────────────────────────────┘

VBA端(按钮事件)

Private Sub btnPredict_Click()    ' 1. 校验输入    If Range("B2").Value = "" Then        MsgBox "请输入历史数据!", vbExclamation        Exit Sub    End If    ' 2. 调用Python    Application.StatusBar = "正在调用Python模型..."    RunPython "import sales_model; sales_model.run_prediction()"    Application.StatusBar = "完成"    ' 3. 刷新图表    ActiveSheet.ChartObjects("SalesChart").Chart.RefreshEnd Sub

Python端(sales_model.py)

import xlwings as xwimport pandas as pdfrom statsmodels.tsa.seasonal import seasonal_decomposefrom sklearn.ensemble import RandomForestRegressordef run_prediction():    wb = xw.Book.caller()    sheet = wb.sheets['数据']    # 读取数据    data = sheet.range('B2:B100').value    data = pd.Series([x for x in data if x is not None])    # 季节性分解    decomposition = seasonal_decompose(data, period=12)    trend = decomposition.trend    seasonal = decomposition.seasonal    # 用随机森林预测趋势    X = pd.DataFrame({'t'range(len(data))})    rf = RandomForestRegressor(n_estimators=100)    rf.fit(X, trend.dropna())    # 预测未来6个月    future_X = pd.DataFrame({'t'range(len(data), len(data) + 6)})    future_trend = rf.predict(future_X)    # 加上季节性成分    last_seasonal = seasonal.tail(12).values    predictions = future_trend + np.tile(last_seasonal[:6], 1)    # 写回Excel    result_sheet = wb.sheets['预测结果']    result_sheet.range('B2').value = predictions.tolist()

八、性能优化与最佳实践

8.1 VBA端优化

  • 关闭屏幕刷新Application.ScreenUpdating = False

  • 关闭自动计算Application.Calculation = xlCalculationManual

  • 批量读写:不要逐个单元格操作,用数组一次性读写

8.2 Python端优化

  • 用pandas向量化操作,避免Python级循环

  • 模型预热:首次调用时加载模型,后续复用

  • 日志输出:用logging模块记录执行过程,方便排查

8.3 架构建议

项目结构:
├── excel_frontend.xlsm      # VBA前端
├── python_backend/
│   ├── __init__.py
│   ├── models/              # 模型定义
│   ├── utils/               # 工具函数
│   └── config.py            # 配置
├── data/                    # 数据文件
└── logs/                    # 日志

九、常见问题排查

问题

原因

解决

Python脚本执行无反应

python.exe不在PATH

用完整路径如C:\Python39\python.exe

xlwings报"Book not set"

未用xw.Book.caller()

确保从Excel内调用

JSON解析失败

Python输出含多余print

确保只输出一个JSON字符串

中文乱码

编码问题

Python端加# -*- coding: utf-8 -*-

执行超时

Python计算太久

VBA端加超时判断或改为异步


十、总结

混合编程的核心不是技术炫技,而是工程思维:让每个工具做它最擅长的事。

  • VBA:Excel的原生语言,操作界面和单元格无人能及

  • Python:数据科学的王者,生态丰富到离谱

两者结合,你得到的不是1+1=2,而是Excel有了"大脑"。

📝 课后练习(5道选择题)

第1题: VBA调用Python脚本时,使用Shell方式获取Python输出,核心依赖哪个对象?

A. Application.Shell

B. WScript.Shell

C. Python.Exec

D. CommandLine

第2题: xlwings中,让Python函数能在Excel公式栏直接调用的装饰器是?

A. @xw.func

B. @xw.sub

C. @xw.udf

D. @xw.formula

第3题: 以下哪项是Shell调用方式的主要缺点?

A. 需要安装第三方库

B. 无法直接捕获Python的标准输出

C. 参数传递麻烦且无法获取返回值

D. 只能在Windows上运行

第4题: 在混合编程架构中,VBA最适合承担的角色是?

A. 复杂数学计算

B. 机器学习建模

C. UI交互和Excel操作

D. 数据库管理

第5题: Python端使用argparse接收参数时,如果参数包含JSON字符串,最可能遇到的问题是?

A. JSON格式不支持

B. 引号转义问题

C. argparse不支持字符串参数

D. 参数长度限制


📋 答案

题号

答案

简要解析

1

B

WScript.Shell的Exec方法可以捕获stdout/stderr

2

A

@xw.func装饰器将函数暴露为Excel用户自定义函数

3

C

Shell调用参数传递依赖命令行字符串,返回值需通过stdout或文件桥接

4

C

VBA的优势在于Excel对象模型操作和用户界面控制

5

B

JSON中的双引号与命令行引号冲突,需要仔细转义处理


最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-21 13:38:21 HTTP/2.0 GET : https://f.mffb.com.cn/a/510452.html
  2. 运行时间 : 0.375870s [ 吞吐率:2.66req/s ] 内存消耗:4,586.27kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=7726e18cbe4b658085dfde3576008249
  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.001196s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001410s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000591s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000595s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001127s ]
  6. SELECT * FROM `set` [ RunTime:0.000546s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001661s ]
  8. SELECT * FROM `article` WHERE `id` = 510452 LIMIT 1 [ RunTime:0.001027s ]
  9. UPDATE `article` SET `lasttime` = 1787290701 WHERE `id` = 510452 [ RunTime:0.096730s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.013241s ]
  11. SELECT * FROM `article` WHERE `id` < 510452 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001287s ]
  12. SELECT * FROM `article` WHERE `id` > 510452 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001112s ]
  13. SELECT * FROM `article` WHERE `id` < 510452 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001614s ]
  14. SELECT * FROM `article` WHERE `id` < 510452 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001797s ]
  15. SELECT * FROM `article` WHERE `id` < 510452 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.065133s ]
0.379274s