当前位置:首页>python>Python ctypes模块详细介绍

Python ctypes模块详细介绍

  • 2026-02-05 00:44:49
Python ctypes模块详细介绍

1. 创始时间与作者

  • 创始时间ctypes 模块首次出现在 Python 2.5 版本中,于 2006年9月 发布

  • 核心开发者

    • Thomas Heller:ctypes 模块的主要作者和长期维护者

    • Python 核心团队:持续改进和扩展功能

    • 社区贡献者:来自全球开发者的改进和平台适配

  • 项目定位:Python 外部函数接口(FFI)库,用于调用 C 语言编写的共享库和系统 API

2. 官方资源

  • Python 官方文档https://docs.python.org/3/library/ctypes.html

  • 源码地址https://github.com/python/cpython/tree/main/Lib/ctypes

  • 教程指南https://docs.python.org/3/library/ctypes.html

  • Ctypes 教程https://docs.python.org/3/library/ctypes.html#tutorial

3. 核心功能

4. 应用场景

1. 基础C库函数调用
import ctypesimport osfrom ctypes import c_intc_doublec_char_pStructurePOINTER# 加载系统C库if os.name == 'nt':  # Windowslibc = ctypes.CDLL('msvcrt.dll')else:  # Linux/Maclibc = ctypes.CDLL('libc.so.6')  # Linux# libc = ctypes.CDLL('libc.dylib')  # macOSdef basic_library_demo():"""基础库函数调用演示"""# 调用C标准库函数# printflibc.printf.restype = c_intlibc.printf.argtypes = [c_char_p]libc.printf(b"Hello from C printf! Number: %d, Float: %.2f\n"423.14159)# strlenlibc.strlen.restype = ctypes.c_size_tlibc.strlen.argtypes = [c_char_p]text = b"Hello, World!"length = libc.strlen(text)print(f"字符串 '{text.decode()}' 的长度: {length}")# atoi - 字符串转整数libc.atoi.restype = c_intlibc.atoi.argtypes = [c_char_p]number = libc.atoi(b"12345")print(f"字符串转整数: {number}")# 数学函数libm = ctypes.CDLL('libm.so.6')  # 数学库libm.sqrt.restype = c_doublelibm.sqrt.argtypes = [c_double]result = libm.sqrt(25.0)print(f"平方根: {result}")# 运行示例basic_library_demo()
2. 自定义C库调用
// math_operations.c - 编译为共享库#include <stdio.h>// 基本数学运算int add(int aint b) {return a+b;}double multiply(double adouble b) {return a*b;}// 字符串操作void reverse_string(char*str) {int length=0;while (str[length!='\0') {length++;    }for (int i=0i<length/2i++) {char temp=str[i];str[i=str[length-i-1];str[length-i-1=temp;    }}// 结构体操作type def struct {int x;int y;Point;double point_distance(Pointp1Pointp2) {int dx=p2.x-p1.x;int dy=p2.y-p1.y;return sqrt(dx*dx+dy*dy);}
import ctypesfrom ctypes import c_intc_doublec_char_pStructurePOINTER# 定义结构体,与C代码匹配class Point(Structure):_fields_ = [("x"c_int),                ("y"c_int)]def custom_library_demo():"""自定义C库调用演示"""try:# 加载自定义库(需要先编译)# gcc -shared -o math_operations.so math_operations.cmath_lib = ctypes.CDLL('./math_operations.so')# 配置函数原型math_lib.add.restype = c_intmath_lib.add.argtypes = [c_intc_int]math_lib.multiply.restype = c_doublemath_lib.multiply.argtypes = [c_doublec_double]math_lib.reverse_string.restype = Nonemath_lib.reverse_string.argtypes = [c_char_p]math_lib.point_distance.restype = c_doublemath_lib.point_distance.argtypes = [PointPoint]# 调用函数result_add = math_lib.add(1020)print(f"加法结果: {result_add}")result_multiply = math_lib.multiply(3.142.0)print(f"乘法结果: {result_multiply}")# 字符串操作(需要可写内存)text = ctypes.create_string_buffer(b"Hello, World!")math_lib.reverse_string(text)print(f"反转字符串: {text.value.decode()}")# 结构体操作p1 = Point(00)p2 = Point(34)distance = math_lib.point_distance(p1p2)print(f"点之间的距离: {distance}")except OSError as e:print(f"无法加载库: {e}")print("请先编译C代码: gcc -shared -o math_operations.so math_operations.c")# 运行示例custom_library_demo()
3. Windows API 调用
import ctypesfrom ctypes import wintypesimport timedef windows_api_demo():"""Windows API 调用演示"""if hasattr(ctypes'windll'):# 加载Windows DLLkernel32 = ctypes.windll.kernel32user32 = ctypes.windll.user32# 获取系统信息# GetComputerNamecomputer_name = ctypes.create_unicode_buffer(16)size = wintypes.DWORD(16)kernel32.GetComputerNameW(computer_namectypes.byref(size))print(f"计算机名: {computer_name.value}")# GetUserNameuser_name = ctypes.create_unicode_buffer(256)size = wintypes.DWORD(256)kernel32.GetUserNameW(user_namectypes.byref(size))print(f"用户名: {user_name.value}")# 系统目录system_dir = ctypes.create_unicode_buffer(260)kernel32.GetSystemDirectoryW(system_dir260)print(f"系统目录: {system_dir.value}")# 窗口操作# 获取前台窗口foreground_window = user32.GetForegroundWindow()# 获取窗口标题window_title = ctypes.create_unicode_buffer(256)user32.GetWindowTextW(foreground_windowwindow_title256)print(f"前台窗口: {window_title.value}")# 鼠标位置class POINT(ctypes.Structure):_fields_ = [("x"wintypes.LONG),                        ("y"wintypes.LONG)]point = POINT()user32.GetCursorPos(ctypes.byref(point))print(f"鼠标位置: ({point.x}, {point.y})")# 系统时间class SYSTEMTIME(ctypes.Structure):_fields_ = [("wYear"wintypes.WORD),                        ("wMonth"wintypes.WORD),                        ("wDayOfWeek"wintypes.WORD),                        ("wDay"wintypes.WORD),                        ("wHour"wintypes.WORD),                        ("wMinute"wintypes.WORD),                        ("wSecond"wintypes.WORD),                        ("wMilliseconds"wintypes.WORD)]system_time = SYSTEMTIME()kernel32.GetLocalTime(ctypes.byref(system_time))print(f"系统时间: {system_time.wYear}-{system_time.wMonth}-{system_time.wDay} "f"{system_time.wHour}:{system_time.wMinute}:{system_time.wSecond}")else:print("此演示仅适用于Windows系统")# 运行示例(Windows系统)windows_api_demo()
4. 高级内存操作和回调
import ctypesfrom ctypes import CFUNCTYPEc_intc_void_pc_char_pStructurePOINTERcastimpor tarraydef advanced_memory_demo():"""高级内存操作演示"""# 内存分配和操作libc = ctypes.CDLL('libc.so.6'if hasattr(ctypes'CDLL'else ctypes.cdll.msvcrt# malloc 和 freelibc.malloc.restype = c_void_plibc.malloc.argtypes = [ctypes.c_size_t]libc.free.restype = Nonelibc.free.argtypes = [c_void_p]# 分配内存size = 100memory_ptr = libc.malloc(size)print(f"分配的内存地址: {hex(memory_ptr)}")# 使用ctypes访问内存char_array = (ctypes.c_char*size).from_address(memory_ptr)# 写入数据test_data = b"Hello from ctypes memory!"for ibyte in enumerate(test_data):if i<size:char_array[i] = byte# 读取数据read_data = bytearray()for in range(min(sizelen(test_data))):read_data.append(char_array[i])print(f"写入的数据: {test_data}")print(f"读取的数据: {read_data.decode()}")# 释放内存libc.free(memory_ptr)# 回调函数演示def callback_function(value):print(f"回调函数被调用,值: {value}")return value*2# 定义回调类型CALLBACK_TYPE = CFUNCTYPE(c_intc_int)# 包装Python函数为C回调c_callback = CALLBACK_TYPE(callback_function)# 模拟调用带回调的C函数def call_with_callback(datacallback):result = 0for in range(data):result += callback(i)return result# 将Python函数转换为C可调用类型callback_wrapper = CFUNCTYPE(c_intc_intCALLBACK_TYPE)(call_with_callback)final_result = callback_wrapper(5c_callback)print(f"回调函数最终结果: {final_result}")# 数组操作print("\n数组操作演示:")IntArray10 = c_int*10arr = IntArray10(12345678910)# 访问数组元素for in range(10):print(f"arr[{i}] = {arr[i]}")# 与Python数组互操作py_array = array.array('i', [1020304050])c_array = (c_int*len(py_array))(*py_array)print(f"Python数组: {py_array.tolist()}")print(f"ctypes数组: {[c_array[i] for i in range(len(py_array))]}")# 运行示例advanced_memory_demo()

5. 底层逻辑与技术原理

核心架构
关键技术
  1. libffi 库集成

    • 外部函数接口库,处理函数调用约定

    • 自动处理参数传递和返回值

    • 支持多种CPU架构和调用约定

  2. 类型映射系统

    # C类型到Python类型的映射c_int<->intc_double<->floatc_char_p<->bytes/strc_void_p<->int (地址)
  3. 内存管理

    • 自动类型转换和内存分配

    • 垃圾收集器集成

    • 手动内存管理支持

  4. 调用约定处理

    • cdecl:C标准调用约定

    • stdcall:Windows API标准

    • fastcall:寄存器参数传递

  5. 平台抽象层

    • 统一的库加载接口

    • 自动库搜索路径处理

    • 错误代码转换

函数调用流程
# ctypes函数调用内部流程1.参数Python对象->C类型转换2.根据调用约定准备栈/寄存器3.通过libffi调用目标函数4.返回值C类型->Python对象转换5.错误代码检查和处理

6. 安装与配置

基础安装
# ctypes 是 Python 标准库的一部分,无需额外安装# 验证安装python -c"import ctypes; print(ctypes.__doc__)"
可选依赖
# 在某些系统上可能需要开发工具# Ubuntu/Debiansudo apt-get install build-essential python3-dev# CentOS/RHELsudo yum install gcc python3-devel# Windows# 安装Visual Studio Build Tools或MinGW
环境要求
组件最低要求推荐配置
Python2.5+3.6+
操作系统Windows/Linux/macOS同左
编译器可选(用于构建C扩展)GCC/Clang/MSVC
平台验证
import ctypesimport platformimport sysdef check_ctypes_environment():"""检查ctypes环境"""print(f"Python版本: {sys.version}")print(f"操作系统: {platform.system()} {platform.release()}")print(f"ctypes版本: {ctypes.__version__}")# 检查库加载能力try:if platform.system() == 'Windows':lib = ctypes.windll.kernel32print("Windows库加载: 正常")else:lib = ctypes.CDLL('libc.so.6')print("Unix库加载: 正常")except Exception as e:print(f"库加载测试失败: {e}")# 检查数据类型支持print(f"支持的数据类型: {[t for t in dir(ctypes) if t.startswith('c_')]}")check_ctypes_environment()

7. 性能指标

操作类型执行时间内存开销适用场景
简单函数调用0.1-1μs可忽略高频调用
复杂结构体操作1-10μs1-100KB数据交换
回调函数1-5μs可忽略事件处理
大内存操作依赖数据大小直接映射数据处理

8. 高级功能使用

1. 复杂结构体和联合
import ctypesfrom ctypes import StructureUnionc_intc_floatc_charc_uint32def advanced_structures_demo():"""高级结构体和联合演示"""# 复杂结构体class Employee(Structure):_fields_ = [            ("id"c_int),            ("name"c_char*50),            ("salary"c_float),            ("department"c_char*30)        ]# 位域结构体class BitField(Structure):_fields_ = [            ("flag1"c_uint321),   # 1位            ("flag2"c_uint321),   # 1位              ("value"c_uint3230),  # 30位        ]# 联合体class DataUnion(Union):_fields_ = [            ("as_int"c_int),            ("as_float"c_float),            ("as_chars"c_char*4)        ]# 嵌套结构体class Address(Structure):_fields_ = [            ("street"c_char*50),            ("city"c_char*30),            ("zipcode"c_char*10)        ]class Person(Structure):_fields_ = [            ("name"c_char*50),            ("age"c_int),            ("address"Address)        ]# 使用结构体emp = Employee()emp.id = 1001emp.name = b"John Doe"emp.salary = 75000.5emp.department = b"Engineering"print(f"员工: ID={emp.id}, 姓名={emp.name.decode()}, "f"薪资={emp.salary}, 部门={emp.department.decode()}")# 使用位域bitfield = BitField()bitfield.flag1 = 1bitfield.flag2 = 0bitfield.value = 12345print(f"位域: flag1={bitfield.flag1}, flag2={bitfield.flag2}, value={bitfield.value}")# 使用联合体data_union = DataUnion()data_union.as_int = 0x41424344# 'ABCD' in ASCIIprint(f"联合体: 整数={data_union.as_int}, "f"浮点数={data_union.as_float}, "f"字符={data_union.as_chars.decode()}")# 使用嵌套结构体addr = Address()addr.street = b"123 Main St"addr.city = b"Anytown"addr.zipcode = b"12345"person = Person()person.name = b"Alice Smith"person.age = 30person.address = addrprint(f"人员: {person.name.decode()}, {person.age}岁, "f"地址: {person.address.street.decode()}, {person.address.city.decode()}")# 运行示例advanced_structures_demo()
2. 动态库创建和调用
import ctypesimport tempfileimport osimport subprocessdef dynamic_library_demo():"""动态库创建和调用演示"""# 创建临时的C源代码c_code = '''#include <stdio.h>#include <stdlib.h>// 导出函数__attribute__((visibility("default")))int fibonacci(int n) {    if (n <= 1) return n;    return fibonacci(n-1) + fibonacci(n-2);}__attribute__((visibility("default"))) void process_array(int* arr, int size, int multiplier) {    for (int i = 0; i < size; i++) {        arr[i] = arr[i] * multiplier;    }}__attribute__((visibility("default")))const char* get_greeting(const char* name) {    static char greeting[100];    snprintf(greeting, sizeof(greeting), "Hello, %s!", name);    return greeting;}'''# 创建临时目录with tempfile.TemporaryDirectory()  as temp_dir:c_file = os.path.join(temp_dir"dynamic_lib.c")so_file = os.path.join(temp_dir"dynamic_lib.so")# 写入C代码with open(c_file'w')  as f:f.write(c_code)try:# 编译为共享库if os.name == 'nt':  # Windowscompile_cmd = f'gcc -shared -o "{so_file}" "{c_file}"'else:  # Linux/macOScompile_cmd = f'gcc -shared -fPIC -o "{so_file}" "{c_file}"'result = subprocess.run(compile_cmdshell=Truecapture_output=Truetext=True)if result.returncode == 0:# 加载动态库dyn_lib = ctypes.CDLL(so_file)# 配置函数原型dyn_lib.fibonacci.restype = ctypes.c_intdyn_lib.fibonacci.argtypes = [ctypes.c_int]dyn_lib.process_array.restype = Nonedyn_lib.process_array.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.c_intctypes.c_int]dyn_lib.get_greeting.restype = ctypes.c_char_pdyn_lib.get_greeting.argtypes = [ctypes.c_char_p]# 测试斐波那契函数print("斐波那契数列:")for in range(10):result = dyn_lib.fibonacci(i)print(f"fib({i}) = {result}")# 测试数组处理print("\n数组处理:")IntArray5 = ctypes.c_int*5arr = IntArray5(12345)print("处理前:", [arr[i]  for in range(5)])dyn_lib.process_array(arr510)print("处理后:", [arr[ifor in range(5)])# 测试字符串函数print("\n字符串处理:")name = b"Python Developer"greeting = dyn_lib.get_greeting(name)print(f"问候语: {greeting.decode()}")else:print(f"编译失败: {result.stderr}")except Exception as e:print(f"动态库演示错误: {e}")print("请确保系统已安装GCC编译器")# 运行示例dynamic_library_demo()

9. 与同类工具对比

特性ctypesCFFICythonctypesgen
学习曲线⭐⭐⭐⭐⭐⭐⭐⭐⭐
性能⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
无需编译⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
类型安全⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
代码生成⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
标准库⭐⭐⭐⭐⭐

10. 安全与最佳实践

安全建议
  1. 输入验证

    def safe_ctype_call(func*args):"""安全的ctypes调用"""# 验证参数类型if not all(isinstance(arg, (intfloatstrbytes))  for arg in args):raise ValueError("无效的参数类型")# 设置合理的超时(如果适用)return func(*args)
  2. 内存安全

    # 使用create_string_buffer而不是直接指针操作buffer = ctypes.create_string_buffer(100)buffer.value = b"Safe data"# 避免内存泄漏class ManagedMemory:def __init__(selfsize):self._ptr = ctypes.c_void_p(libc.malloc(size))def __del__(self):if self._ptr:libc.free(self._ptr)
  3. 错误处理

    def robust_library_call():try:result = some_c_function()if result == -1:  # 假设-1表示错误# 获取错误信息error_msg = ctypes.c_char_p()get_error_message(ctypes.byref(error_msg))raise RuntimeError(f"C函数错误: {error_msg.value.decode()}")return resultexcept OSError as e:raise RuntimeError(f"库调用失败: {e}")
最佳实践
import ctypesfrom ctypes import Structurec_intc_char_pPOINTERclass CTypesWrapper:"""ctypes包装器最佳实践"""def __init__(selflibrary_path):self.lib = ctypes.CDLL(library_path)self._configure_functions()def _configure_functions(self):"""配置所有函数原型"""# 示例配置if hasattr(self.lib'some_function'):self.lib.some_function.restype = c_intself.lib.some_function.argtypes = [c_intc_char_p]def safe_call(selffunc_name*args):"""安全函数调用"""func = getattr(self.libfunc_nameNone)if not func:raise AttributeError(f"函数 {func_name} 不存在")try:return func(*args)except Exception as e:raise RuntimeError(f"调用 {func_name} 失败: {e}")def __enter__(self):return selfdef __exit__(selfexc_typeexc_valexc_tb):# 清理资源if hasattr(self.lib'cleanup'):self.lib.cleanup()# 使用示例with CTypesWrapper('mylib.so')  as wrapper:result = wrapper.safe_call('some_function'42b"test")

11. 企业级应用案例

  1. 系统工具开发

    • 进程监控和管理工具

    • 系统信息收集工具

  2. 硬件交互

    • 设备驱动程序接口

    • 硬件性能监控

  3. 性能优化

    • 高性能计算库包装

    • 数学和科学计算

  4. 游戏开发

    • 游戏引擎接口

    • 图形库绑定

  5. 安全工具

    • 系统安全监控

    • 加密库接口


总结

ctypes 是 Python 与 C 语言交互的桥梁,核心价值在于:

  1. 无需编译:直接调用现有C库,无需编写C扩展

  2. 跨平台:统一的API支持Windows、Linux、macOS

  3. 简单易用:直观的Pythonic接口设计

  4. 功能强大:支持复杂数据类型和回调函数

技术亮点

  • 基于libffi的高效函数调用

  • 完整的C类型系统支持

  • 灵活的内存管理机制

  • 强大的错误处理能力

适用场景

  • 调用系统API和现有C库

  • 快速原型开发和概念验证

  • 性能关键组件的C语言实现

  • 跨语言集成和系统编程

安装使用

# 无需安装,直接导入python -c"import ctypes; print('ctypes 模块可用')"

学习资源

  • 官方文档:https://docs.python.org/3/library/ctypes.html

  • 教程指南:https://docs.python.org/3/library/ctypes.html#tutorial

  • 实战示例:https://realpython.com/python-ctypes/

ctypes 作为 Python 标准库的重要组成部分,为 Python 开发者打开了直接与底层系统交互的大门,是系统编程、性能优化和跨语言集成的强大工具。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-08 05:58:19 HTTP/2.0 GET : https://f.mffb.com.cn/a/471519.html
  2. 运行时间 : 1.115794s [ 吞吐率:0.90req/s ] 内存消耗:5,012.88kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=42a23ee4b7d1769cb3c319b89b389028
  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.001090s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001488s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.001234s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000701s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001364s ]
  6. SELECT * FROM `set` [ RunTime:0.001392s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001585s ]
  8. SELECT * FROM `article` WHERE `id` = 471519 LIMIT 1 [ RunTime:0.034058s ]
  9. UPDATE `article` SET `lasttime` = 1770501499 WHERE `id` = 471519 [ RunTime:0.008318s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.002742s ]
  11. SELECT * FROM `article` WHERE `id` < 471519 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.018218s ]
  12. SELECT * FROM `article` WHERE `id` > 471519 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.004135s ]
  13. SELECT * FROM `article` WHERE `id` < 471519 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.646764s ]
  14. SELECT * FROM `article` WHERE `id` < 471519 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.058644s ]
  15. SELECT * FROM `article` WHERE `id` < 471519 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.180804s ]
1.117449s