当前位置:首页>python>Python与C交互利器:create_string_buffer() 深度解析

Python与C交互利器:create_string_buffer() 深度解析

  • 2026-03-28 15:43:54
Python与C交互利器:create_string_buffer() 深度解析

ctypes 是 Python 的一个外部函数库,它提供了与 C 语言兼容的数据类型,并允许调用动态链接库/共享库中的函数。create_string_buffer() 是 ctypes 模块中一个非常有用的函数,它用于创建一个可修改的 C 风格字符串缓冲区(即字符数组)。

1. create_string_buffer() 基本概念

create_string_buffer() 函数用于创建一个字符数组(C 风格的字符串缓冲区),这个缓冲区是可修改的,与 Python 的不可变字符串不同。它主要有以下特点:

  • • 可以预先分配指定大小的缓冲区
  • • 可以初始化缓冲区内容
  • • 允许通过索引或切片修改内容
  • • 可以与 C 函数交互,作为字符指针传递

函数签名

ctypes.create_string_buffer(init_or_size, size=None)

参数:

  • • init_or_size:可以是整数(指定缓冲区大小)或字符串(初始化缓冲区内容)
  • • size:可选参数,当第一个参数是字符串时指定缓冲区大小

返回值:

  • • 返回一个 ctypes.c_char_Array 类型的实例

2. 基本用法示例

示例 1:创建指定大小的空缓冲区

from ctypes import create_string_buffer# 创建一个大小为10的空字符缓冲区buf = create_string_buffer(10)print(f"Buffer size: {len(buf)}")  # 输出: Buffer size: 10print(f"Raw buffer: {buf.raw}")    # 输出原始字节内容,如 b'\x00\x00\x00...'

示例 2:创建并初始化缓冲区

# 创建一个并初始化为 "Hello" 的缓冲区buf = create_string_buffer(b"Hello")print(f"Buffer content: {buf.value.decode('utf-8')}")  # 输出: Helloprint(f"Buffer size: {len(buf)}")  # 输出: 5 (字符串长度)

示例 3:指定大小和初始内容

# 创建大小为10的缓冲区,初始内容为 "Hi"buf = create_string_buffer(b"Hi"10)print(f"Buffer content: {buf.value.decode('utf-8')}")  # 输出: Hiprint(f"Buffer raw: {buf.raw}")  # 输出: b'Hi\x00\x00\x00\x00\x00\x00' (剩余部分用null填充)

3. 修改缓冲区内容

create_string_buffer() 创建的缓冲区是可修改的,可以通过多种方式修改其内容:

示例 4:通过索引修改

buf = create_string_buffer(b"Hello")buf[0] = ord('h')  # 将 'H' 改为 'h'print(f"Modified buffer: {buf.value.decode('utf-8')}")  # 输出: hello

示例 5:通过切片修改

buf = create_string_buffer(10)buf[:5] = b"World"# 修改前5个字节print(f"Buffer content: {buf.raw}")  # 输出: b'World\x00\x00\x00\x00\x00'

示例 6:修改整个缓冲区

buf = create_string_buffer(b"Original")new_content = b"New Content"# 确保新内容不超过缓冲区大小iflen(new_content) <= len(buf):    buf[:len(new_content)] = new_contentelse:print("Error: New content too large")print(f"Buffer content: {buf.value.decode('utf-8')}")  # 输出: New Cont

4. 与 C 函数交互

create_string_buffer() 的主要用途之一是与 C 函数交互,特别是那些需要修改字符串内容的函数。

示例 7:模拟 C 的 strcpy 函数

from ctypes import *# 定义一个模拟的 C 函数 (在实际中,这会是从 DLL/SO 加载的)defmy_strcpy(dest, src):"""模拟 C 的 strcpy 函数"""for i inrange(len(src)):        dest[i] = src[i]    dest[len(src)] = b'\x00'[0]  # 添加 null 终止符# 创建目标缓冲区dest_buf = create_string_buffer(20)src_str = b"Hello from Python"# 调用模拟函数my_strcpy(dest_buf, src_str)print(f"Copied string: {dest_buf.value.decode('utf-8')}")  # 输出: Hello from Python

示例 8:与实际 C 库交互 (Windows API)

from ctypes import *from ctypes.wintypes import *# 加载 kernel32.dllkernel32 = windll.kernel32# 定义 GetComputerNameA 函数原型kernel32.GetComputerNameA.argtypes = [LPSTR, LPDWORD]kernel32.GetComputerNameA.restype = BOOL# 创建缓冲区buffer_size = 256buffer = create_string_buffer(buffer_size)size = DWORD(buffer_size)# 调用函数if kernel32.GetComputerNameA(buffer, byref(size)):print(f"Computer name: {buffer.value.decode('utf-8')}")else:print("Failed to get computer name")

5. 高级用法

示例 9:创建 Unicode 字符串缓冲区

虽然 create_string_buffer() 主要用于字节字符串,但可以结合 c_wchar 数组处理 Unicode:

from ctypes import *# 创建 Unicode 字符串缓冲区 (Python 3 中更推荐使用 create_unicode_buffer)# 但这里演示如何用 c_wchar 数组实现类似功能defcreate_unicode_buffer(size):return (c_wchar * size)()# 或者更简单的方式 (Python 3 的 ctypes 已有 create_unicode_buffer)# buf = create_unicode_buffer(10)# 使用 create_unicode_buffer (Python 3 内置)buf = create_unicode_buffer(10)buf.value = "Hello"print(f"Unicode buffer: {buf.value}")  # 输出: Hello

注意:Python 3 中更推荐使用 create_unicode_buffer() 处理 Unicode 字符串。

示例 10:缓冲区重用

buf = create_string_buffer(100)defprocess_data(data):global buf# 确保缓冲区足够大iflen(data) > len(buf):        buf = create_string_buffer(len(data) * 2)  # 分配更大的缓冲区# 处理数据 (这里简单复制)    buf[:len(data)] = datareturn buf.raw# 使用缓冲区result1 = process_data(b"First data")result2 = process_data(b"Second data is longer and needs more space")print(f"Result 1: {result1}")print(f"Result 2: {result2}")

6. 实际应用案例

案例 1:读取二进制文件到缓冲区并修改

from ctypes import create_string_bufferdefread_and_modify_file(filename):try:# 读取文件内容withopen(filename, 'rb'as f:            data = f.read()# 创建缓冲区        buf = create_string_buffer(data)# 修改缓冲区内容 (示例: 将所有 'A' 改为 'B')for i inrange(len(buf)):if buf[i] == ord('A'):                buf[i] = ord('B')# 将修改后的内容写回文件withopen(filename + '.modified''wb'as f:            f.write(buf.raw)print("File processed successfully")except Exception as e:print(f"Error: {e}")# 使用示例read_and_modify_file('example.bin')

案例 2:与 C 程序交互 - 简单的加密/解密

假设我们有一个 C 库提供简单的加密/解密功能:

C 代码 (simple_crypto.c):

#include<string.h>// 简单的 XOR 加密/解密voidxor_crypt(char *data, int length, char key) {for (int i = 0; i < length; i++) {        data[i] ^= key;    }}

编译为共享库:

gcc -shared -o libsimplecrypto.so -fPIC simple_crypto.c

Python 代码:

from ctypes import *# 加载共享库lib = CDLL('./libsimplecrypto.so')# 定义函数原型lib.xor_crypt.argtypes = [POINTER(c_char), c_int, c_char]lib.xor_crypt.restype = None# 要加密的数据data = b"Hello, this is a secret message!"key = ord('K')  # 使用 'K' 作为密钥# 创建缓冲区 (确保足够大)buf = create_string_buffer(data)original_len = len(data)print(f"Original: {data}")# 加密lib.xor_crypt(buf, original_len, key)encrypted = bytes(buf.raw[:original_len])print(f"Encrypted: {encrypted}")# 解密 (再次调用相同的函数)lib.xor_crypt(buf, original_len, key)decrypted = bytes(buf.raw[:original_len])print(f"Decrypted: {decrypted.decode('utf-8')}")

7. 性能考虑

create_string_buffer() 创建的缓冲区在内存中是连续的,这使得它非常适合需要高性能操作的场景:

性能测试示例

import timefrom ctypes import create_string_bufferdeftest_buffer_performance():    size = 1024 * 1024# 1MB# 方法1: 使用 create_string_buffer    start = time.time()    buf1 = create_string_buffer(size)for i inrange(0, size, 4096):  # 每4KB修改一次        buf1[i] = 1    time_buf = time.time() - start# 方法2: 使用 bytearray (Python原生可变字节序列)    start = time.time()    buf2 = bytearray(size)for i inrange(0, size, 4096):        buf2[i] = 1    time_bytearray = time.time() - startprint(f"create_string_buffer time: {time_buf:.4f} seconds")print(f"bytearray time: {time_bytearray:.4f} seconds")print(f"bytearray is {time_bytearray/time_buf:.2f}x faster")test_buffer_performance()

结果分析

  • • 对于简单的逐元素修改,bytearray 通常比 create_string_buffer 更快
  • • 但当需要与 C 函数交互时,create_string_buffer 是更好的选择
  • • 对于大块内存操作(如使用 memmove 或 memcpy),create_string_buffer 可能更高效

8. 安全注意事项

  1. 1. 缓冲区溢出:确保不写入超过缓冲区大小的数据
    buf = create_string_buffer(10)# 危险操作 - 可能溢出# buf[:20] = b"This is way too long for the buffer"# 安全做法data = b"Safe data"iflen(data) <= len(buf):    buf[:len(data)] = data
  2. 2. null 终止符:C 字符串通常需要 null 终止符
    buf = create_string_buffer(b"Hello")  # 自动添加 null# 或者手动确保buf = create_string_buffer(6)  # 额外空间给 nullbuf[:5] = b"Hello"buf[5] = 0# 添加 null 终止符
  3. 3. 线程安全create_string_buffer 创建的缓冲区本身不是线程安全的,需要外部同步

9. 替代方案比较

方法
可变性
C 兼容性
性能
适用场景
bytes
不可变
是 (只读)
需要不可变字节序列
bytearray
可变
最高
纯 Python 字节序列操作
create_string_buffer
可变
需要与 C 交互的可变缓冲区
array.array('B')
可变
有限
数值数组操作

10. 完整示例:实现一个简单的 C 风格字符串处理类

from ctypes import *classCStringBuffer:def__init__(self, initial=None, size=None):"""        初始化 C 风格字符串缓冲区        :param initial: 初始字符串或字节串        :param size: 缓冲区大小 (如果 initial 是字符串)        """if initial isnotNoneand size isnotNone:self.buf = create_string_buffer(initial, size)elif initial isnotNone:ifisinstance(initial, str):                initial = initial.encode('utf-8')self.buf = create_string_buffer(initial)elif size isnotNone:self.buf = create_string_buffer(size)else:raise ValueError("Either initial or size must be provided")    @propertydefvalue(self):"""获取缓冲区内容作为字符串"""returnself.buf.value.decode('utf-8')    @value.setterdefvalue(self, new_value):"""设置缓冲区内容"""ifisinstance(new_value, str):            new_value = new_value.encode('utf-8')iflen(new_value) > len(self.buf):raise ValueError("New value too large for buffer")self.buf[:len(new_value)] = new_value# 确保 null 终止 (如果缓冲区有剩余空间)iflen(new_value) < len(self.buf):self.buf[len(new_value)] = 0def__len__(self):"""返回缓冲区大小"""returnlen(self.buf)def__str__(self):"""字符串表示"""returnself.valuedef__getitem__(self, index):"""获取单个字符"""returnself.buf[index]def__setitem__(self, index, value):"""设置单个字符"""self.buf[index] = valuedefto_bytes(self):"""获取原始字节 (包括可能的 null 终止符)"""returnbytes(self.buf.raw)defclear(self):"""清空缓冲区"""self.buf[:] = b'\x00' * len(self.buf)# 使用示例if __name__ == "__main__":# 创建缓冲区    cbuf = CStringBuffer("Hello"20)print(f"Initial: {cbuf}")  # Helloprint(f"Length: {len(cbuf)}")  # 20 (缓冲区大小)print(f"Raw bytes: {cbuf.to_bytes()}")# 修改内容    cbuf.value = "World"print(f"Modified: {cbuf}")  # World# 通过索引修改    cbuf[0] = ord('w')print(f"After index modification: {cbuf}")  # world# 清空    cbuf.clear()print(f"After clear: '{cbuf.value}'")  # '' (空字符串)

总结

ctypes.create_string_buffer() 是 Python 中处理 C 风格字符串缓冲区的强大工具,特别适用于需要与 C 代码交互的场景。它的主要特点包括:

  1. 1. 创建可修改的字符缓冲区
  2. 2. 可以指定初始内容和大小
  3. 3. 支持通过索引和切片修改内容
  4. 4. 与 C 函数兼容,可以传递字符指针
  5. 5. 内存布局与 C 字符串一致

主要应用场景:

  • • 调用需要修改字符串参数的 C 函数
  • • 处理二进制数据
  • • 实现高性能的字符串操作
  • • 与底层系统 API 交互

使用时需要注意:

  • • 缓冲区大小限制
  • • null 终止符的处理
  • • 线程安全性
  • • 与 Python 其他字符串类型的转换

通过合理使用 create_string_buffer(),可以在 Python 中高效地处理需要可变性的 C 风格字符串操作。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-28 16:33:50 HTTP/2.0 GET : https://f.mffb.com.cn/a/483543.html
  2. 运行时间 : 0.174585s [ 吞吐率:5.73req/s ] 内存消耗:4,873.43kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=55bfe2012b3f1f8a2f4c66b6adb6afbf
  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.000448s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000597s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000279s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000290s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000476s ]
  6. SELECT * FROM `set` [ RunTime:0.000211s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000607s ]
  8. SELECT * FROM `article` WHERE `id` = 483543 LIMIT 1 [ RunTime:0.002508s ]
  9. UPDATE `article` SET `lasttime` = 1774686830 WHERE `id` = 483543 [ RunTime:0.000785s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000250s ]
  11. SELECT * FROM `article` WHERE `id` < 483543 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000537s ]
  12. SELECT * FROM `article` WHERE `id` > 483543 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.009510s ]
  13. SELECT * FROM `article` WHERE `id` < 483543 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.019577s ]
  14. SELECT * FROM `article` WHERE `id` < 483543 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.022666s ]
  15. SELECT * FROM `article` WHERE `id` < 483543 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.049412s ]
0.176712s