当前位置:首页>python>Python File(文件)方法详解

Python File(文件)方法详解

  • 2026-06-14 09:38:22
Python File(文件)方法详解

1. 概述

在Python中,文件对象(File Object)是用于操作文件的接口。当使用open()函数打开一个文件时,会返回一个文件对象。这个对象提供了一系列方法,用于读取、写入、定位和管理文件。

1.1 文件的打开与关闭

# 打开文件
file=open("example.txt","r")

# 操作文件
content =file.read()

# 关闭文件
file.close()

# 使用with语句自动关闭文件(推荐)
withopen("example.txt","r")asfile:
    content =file.read()
# 文件会自动关闭

1.2 文件操作模式

模式
描述
r
只读模式(默认)
w
写入模式(覆盖原有内容)
a
追加模式(在文件末尾添加内容)
x
独占创建模式(如果文件已存在则报错)
b
二进制模式
t
文本模式(默认)
+
读写模式

2. 文件读取方法

2.1 read(size=-1)

功能:从文件中读取指定字节数的内容,默认读取所有内容。

参数

  • size
    :可选参数,指定要读取的字节数,默认值为-1(读取所有内容)。

返回值

  • 读取的内容(字符串或字节串,取决于文件打开模式)。

示例

# 读取所有内容
withopen("example.txt","r")asfile:
    content =file.read()
print(content)

# 读取前10个字节
withopen("example.txt","r")asfile:
    content =file.read(10)
print(content)

2.2 readline(size=-1)

功能:从文件中读取一行内容。

参数

  • size
    :可选参数,指定最多读取的字节数。

返回值

  • 读取的行内容(字符串或字节串),包含行尾的换行符。

示例

# 逐行读取文件
withopen("example.txt","r")asfile:
    line1 =file.readline()
    line2 =file.readline()
print("第一行:", line1, end="")
print("第二行:", line2, end="")

# 读取一行的前5个字符
withopen("example.txt","r")asfile:
    partial_line =file.readline(5)
print("前5个字符:", partial_line)

2.3 readlines(hint=-1)

功能:从文件中读取所有行,返回一个列表。

参数

  • hint
    :可选参数,指定大致的字节数,用于优化性能。

返回值

  • 包含所有行内容的列表,每行作为一个元素。

示例

# 读取所有行到列表
withopen("example.txt","r")asfile:
    lines =file.readlines()
print("行数量:",len(lines))
for i, line inenumerate(lines):
print(f"第{i+1}行:", line, end="")

2.4 readinto(buffer)

功能:将文件内容读取到一个可变缓冲区中。

参数

  • buffer
    :可变缓冲区对象(如bytearray)。

返回值

  • 实际读取的字节数。

示例

# 使用readinto读取文件
withopen("example.txt","rb")asfile:
buffer=bytearray(10)
    bytes_read =file.readinto(buffer)
print("读取的字节数:", bytes_read)
print("缓冲区内容:",buffer)
print("实际内容:",buffer[:bytes_read].decode("utf-8"))

3. 文件写入方法

3.1 write(string)

功能:将字符串或字节串写入文件。

参数

  • string
    :要写入的字符串或字节串。

返回值

  • 实际写入的字符数或字节数。

示例

# 写入字符串
withopen("output.txt","w")asfile:
    chars_written =file.write("Hello, World!\n")
print(f"写入的字符数: {chars_written}")
file.write("Python is awesome!\n")

# 写入字节串
withopen("binary.dat","wb")asfile:
    bytes_written =file.write(b"Hello, Binary!\n")
print(f"写入的字节数: {bytes_written}")

3.2 writelines(sequence)

功能:将字符串或字节串序列写入文件。

参数

  • sequence
    :字符串或字节串的序列(如列表、元组)。

返回值

  • 无返回值(None)。

示例

# 写入字符串列表
withopen("output.txt","w")asfile:
    lines =["Line 1\n","Line 2\n","Line 3\n"]
file.writelines(lines)

# 写入生成器表达式
withopen("output.txt","w")asfile:
file.writelines(f"Line {i}\n"for i inrange(1,4))

3.3 flush()

功能:将缓冲区的内容立即写入文件,而不等待缓冲区满。

参数:无

返回值:无返回值(None)。

示例

# 使用flush立即写入
withopen("output.txt","w")asfile:
file.write("First line\n")
file.flush()# 立即写入文件
file.write("Second line\n")

4. 文件指针操作

4.1 tell()

功能:返回当前文件指针的位置(从文件开头算起的字节数)。

参数:无

返回值

  • 当前文件指针的位置(整数)。

示例

withopen("example.txt","r")asfile:
print("初始指针位置:",file.tell())
    content =file.read(5)
print("读取的内容:", content)
print("当前指针位置:",file.tell())

4.2 seek(offset, whence=0)

功能:移动文件指针到指定位置。

参数

  • offset
    :偏移量(字节数)。
  • whence
    :可选参数,指定参考位置:
    • 0:从文件开头算起(默认)
    • 1:从当前位置算起
    • 2:从文件末尾算起

返回值

  • 移动后的文件指针位置(整数)。

示例

withopen("example.txt","r")asfile:
# 从开头偏移5个字节
file.seek(5)
print("偏移5个字节后读取:",file.read(10))

# 从当前位置偏移3个字节
file.seek(3,1)
print("再偏移3个字节后读取:",file.read(10))

# 从末尾偏移-10个字节(读取最后10个字节)
file.seek(-10,2)
print("最后10个字节:",file.read())

4.3 seekable()

功能:判断文件对象是否支持随机访问(即是否可以使用seek()方法)。

参数:无

返回值

  • 如果支持随机访问,返回True;否则返回False。

示例

# 普通文件支持随机访问
withopen("example.txt","r")asfile:
print("普通文件是否支持seek:",file.seekable())# True

# 标准输入不支持随机访问
import sys
print("标准输入是否支持seek:", sys.stdin.seekable())# False

5. 文件属性和状态

5.1 closed

功能:判断文件是否已关闭。

类型:属性

返回值

  • 如果文件已关闭,返回True;否则返回False。

示例

file=open("example.txt","r")
print("文件是否已关闭:",file.closed)# False
file.close()
print("文件是否已关闭:",file.closed)# True

withopen("example.txt","r")asfile:
print("with块内文件是否已关闭:",file.closed)# False
print("with块外文件是否已关闭:",file.closed)# True

5.2 mode

功能:获取文件的打开模式。

类型:属性

返回值

  • 文件的打开模式字符串。

示例

withopen("example.txt","rb+")asfile:
print("文件打开模式:",file.mode)# rb+

5.3 name

功能:获取文件的名称。

类型:属性

返回值

  • 文件的名称字符串。

示例

withopen("example.txt","r")asfile:
print("文件名称:",file.name)# example.txt

# 使用绝对路径
import os
abs_path = os.path.abspath("example.txt")
withopen(abs_path,"r")asfile:
print("文件绝对路径:",file.name)# 完整路径

5.4 encoding

功能:获取文件的编码格式(仅适用于文本模式)。

类型:属性

返回值

  • 文件的编码格式字符串。

示例

withopen("example.txt","r", encoding="utf-8")asfile:
print("文件编码:",file.encoding)# utf-8

5.5 errors

功能:获取文件的错误处理模式(仅适用于文本模式)。

类型:属性

返回值

  • 文件的错误处理模式字符串。

示例

withopen("example.txt","r", encoding="utf-8", errors="replace")asfile:
print("错误处理模式:",file.errors)# replace

5.6 line_buffering

功能:判断文件是否启用行缓冲。

类型:属性

返回值

  • 如果启用行缓冲,返回True;否则返回False。

示例

# 默认情况下,普通文件不启用行缓冲
withopen("example.txt","r")asfile:
print("是否启用行缓冲:",file.line_buffering)# False

5.7 newlines

功能:获取文件中使用的换行符类型。

类型:属性

返回值

  • 如果文件以文本模式打开并读取了内容,返回换行符类型;否则返回None。

示例

withopen("example.txt","r")asfile:
    content =file.read()
print("换行符类型:",file.newlines)

5.8 readable()

功能:判断文件是否可读。

参数:无

返回值

  • 如果文件可读,返回True;否则返回False。

示例

withopen("example.txt","r")asfile:
print("文件是否可读:",file.readable())# True

withopen("output.txt","w")asfile:
print("只写文件是否可读:",file.readable())# False

5.9 writable()

功能:判断文件是否可写。

参数:无

返回值

  • 如果文件可写,返回True;否则返回False。

示例

withopen("example.txt","r")asfile:
print("只读文件是否可写:",file.writable())# False

withopen("output.txt","w")asfile:
print("文件是否可写:",file.writable())# True

5.10 isatty()

功能:判断文件对象是否连接到终端设备。

参数:无

返回值

  • 如果连接到终端设备,返回True;否则返回False。

示例

import sys

# 标准输入、输出、错误是否连接到终端
print("stdin isatty:", sys.stdin.isatty())
print("stdout isatty:", sys.stdout.isatty())
print("stderr isatty:", sys.stderr.isatty())

# 普通文件是否连接到终端
withopen("example.txt","r")asfile:
print("普通文件 isatty:",file.isatty())# False

6. 其他文件方法

6.1 close()

功能:关闭文件对象,释放文件资源。

参数:无

返回值:无返回值(None)。

示例

file=open("example.txt","r")
content =file.read()
file.close()# 关闭文件
print("文件是否已关闭:",file.closed)# True

# 再次操作已关闭的文件会引发错误
try:
file.read()
except ValueError as e:
print("错误:", e)

6.2 detach()

功能:将文件对象与底层二进制缓冲区分离。

参数:无

返回值

  • 分离后的二进制缓冲区对象。

示例

# 在文本模式下分离二进制缓冲区
withopen("example.txt","r+")asfile:
print("分离前编码:",file.encoding)
buffer=file.detach()
print("分离后的缓冲区类型:",type(buffer))
# 现在只能使用二进制操作
buffer.write(b"\nAppended binary data")
buffer.seek(0)
print("读取缓冲区内容:",buffer.read().decode("utf-8"))

6.3 fileno()

功能:返回文件的文件描述符(整数)。

参数:无

返回值

  • 文件描述符(整数)。

示例

withopen("example.txt","r")asfile:
    fd =file.fileno()
print("文件描述符:", fd)

# 使用os模块操作文件描述符
import os
    os.lseek(fd,0, os.SEEK_SET)# 移动文件指针到开头
    content = os.read(fd,10)
print("使用文件描述符读取:", content.decode("utf-8"))

6.4 truncate(size=None)

功能:将文件截断到指定大小。

参数

  • size
    :可选参数,指定截断后的文件大小(字节数)。如果不指定,默认截断到当前文件指针位置。

返回值

  • 截断后的文件大小(整数)。

示例

# 创建一个测试文件
withopen("test_truncate.txt","w")asfile:
file.write("This is a test file for truncate method.")

withopen("test_truncate.txt","r+")asfile:
print("原始文件内容:",file.read())
file.seek(10)# 移动到第10个字节后
    new_size =file.truncate()# 截断到当前位置
print("截断后的大小:", new_size)

file.seek(0)# 回到开头
print("截断后的内容:",file.read())

file.truncate(5)# 截断到5个字节
file.seek(0)
print("再次截断后的内容:",file.read())

6.5 __next__()

功能:返回文件的下一行内容,用于迭代文件对象。

参数:无

返回值

  • 文件的下一行内容(字符串或字节串)。
  • 如果已到达文件末尾,引发StopIteration异常。

示例

# 使用__next__()迭代文件
withopen("example.txt","r")asfile:
try:
whileTrue:
            line =next(file)# 等价于file.__next__()
print("行内容:", line, end="")
except StopIteration:
print("已到达文件末尾")

# 更简洁的迭代方式
withopen("example.txt","r")asfile:
for line infile:
print("行内容:", line, end="")

7. 文件对象的上下文管理器

7.1 __enter__()

功能:在进入with语句块时调用,返回文件对象本身。

参数:无

返回值

  • 文件对象本身。

7.2 __exit__(exc_type, exc_val, exc_tb)

功能:在退出with语句块时调用,自动关闭文件。

参数

  • exc_type
    :异常类型(如果有)
  • exc_val
    :异常值(如果有)
  • exc_tb
    :异常回溯信息(如果有)

返回值

  • 如果返回True,异常会被抑制;否则异常会被重新抛出。

示例

# 使用with语句管理文件对象
withopen("example.txt","r")asfile:
    content =file.read()
print("文件内容:", content)
# 文件会自动关闭
print("文件是否已关闭:",file.closed)# True

# 手动实现上下文管理器的效果
try:
file=open("example.txt","r")
    content =file.read()
print("文件内容:", content)
finally:
file.close()
print("文件是否已关闭:",file.closed)# True

8. 文件操作的最佳实践

8.1 始终使用with语句

使用with语句可以确保文件在使用后自动关闭,避免资源泄漏:

# 推荐
withopen("example.txt","r")asfile:
    content =file.read()

# 不推荐
file=open("example.txt","r")
content =file.read()
file.close()# 可能因为异常而没有执行

8.2 指定正确的文件编码

在处理文本文件时,始终指定字符编码:

# 推荐
withopen("example.txt","r", encoding="utf-8")asfile:
    content =file.read()

# 不推荐(依赖系统默认编码)
withopen("example.txt","r")asfile:
    content =file.read()

8.3 处理文件操作异常

使用try-except语句处理可能的文件操作异常:

try:
withopen("nonexistent.txt","r")asfile:
        content =file.read()
except FileNotFoundError:
print("错误: 文件不存在")
except PermissionError:
print("错误: 没有文件访问权限")
except UnicodeDecodeError:
print("错误: 文件编码错误")
except Exception as e:
print(f"错误: {e}")

8.4 逐行处理大文件

对于大文件,使用迭代方式逐行处理,避免占用过多内存:

# 推荐:逐行处理大文件
withopen("large_file.txt","r")asfile:
for line infile:
        process_line(line)# 处理每一行

# 不推荐:一次性读取所有内容
withopen("large_file.txt","r")asfile:
    content =file.read()# 可能占用大量内存
    lines = content.split("\n")
for line in lines:
        process_line(line)

8.5 使用合适的文件模式

根据需要选择合适的文件操作模式:

# 读取文本文件
withopen("text.txt","r", encoding="utf-8")asfile:
    content =file.read()

# 写入文本文件(覆盖)
withopen("text.txt","w", encoding="utf-8")asfile:
file.write("新内容")

# 追加文本文件
withopen("text.txt","a", encoding="utf-8")asfile:
file.write("\n追加内容")

# 读写二进制文件
withopen("binary.dat","rb+")asfile:
    data =file.read()
file.write(b"\n追加二进制数据")

8.6 及时关闭文件(如果不使用with语句)

如果因为某些原因不能使用with语句,确保在使用完文件后及时关闭:

file=None
try:
file=open("example.txt","r")
    content =file.read()
# 处理文件内容
finally:
iffileandnotfile.closed:
file.close()

9. 常见问题与解决方案

9.1 文件编码问题

问题:读取文件时出现UnicodeDecodeError。

解决方案:尝试使用不同的编码或错误处理模式:

# 尝试不同的编码
encodings =["utf-8","gbk","gb2312","latin-1"]

for encoding in encodings:
try:
withopen("example.txt","r", encoding=encoding)asfile:
            content =file.read()
print(f"使用{encoding}编码成功读取")
break
except UnicodeDecodeError:
print(f"使用{encoding}编码读取失败")

# 使用错误处理模式
withopen("example.txt","r", encoding="utf-8", errors="replace")asfile:
    content =file.read()# 无法解码的字符会被替换为�

withopen("example.txt","r", encoding="utf-8", errors="ignore")asfile:
    content =file.read()# 无法解码的字符会被忽略

9.2 文件指针位置错误

问题:读取或写入文件时,内容与预期不符。

解决方案:使用tell()和seek()方法检查和调整文件指针位置:

withopen("example.txt","r+")asfile:
# 检查当前指针位置
print("当前指针位置:",file.tell())

# 读取一些内容
    content =file.read(10)
print("读取的内容:", content)
print("读取后的指针位置:",file.tell())

# 写入内容(会从当前指针位置开始)
file.write("INSERTED")

# 回到文件开头查看完整内容
file.seek(0)
print("完整内容:",file.read())

9.3 文件权限问题

问题:打开文件时出现PermissionError。

解决方案:检查文件权限和路径:

import os

file_path ="example.txt"

# 检查文件是否存在
ifnot os.path.exists(file_path):
print("错误: 文件不存在")
else:
# 检查文件权限
print("可读:", os.access(file_path, os.R_OK))
print("可写:", os.access(file_path, os.W_OK))
print("可执行:", os.access(file_path, os.X_OK))

# 检查文件所有者和权限模式
    stat_info = os.stat(file_path)
print("文件权限模式:",oct(stat_info.st_mode)[-3:])

9.4 文件打开过多问题

问题:打开文件过多导致OSError: [Errno 24] Too many open files。

解决方案:使用with语句确保文件及时关闭,或增加系统文件描述符限制:

# 错误示例:打开过多文件
files =[]
try:
for i inrange(10000):
        files.append(open(f"file_{i}.txt","w"))
        files[-1].write(f"Content {i}")
except OSError as e:
print("错误:", e)
finally:
# 关闭所有打开的文件
forfilein files:
ifnotfile.closed:
file.close()

# 正确示例:使用with语句
for i inrange(100):
withopen(f"file_{i}.txt","w")asfile:
file.write(f"Content {i}")

10. 总结

Python的文件对象提供了丰富的方法,用于读取、写入、定位和管理文件。这些方法可以分为以下几类:

  1. 文件读取方法
    read()readline()readlines()readinto()
  2. 文件写入方法
    write()writelines()flush()
  3. 文件指针操作
    tell()seek()seekable()
  4. 文件属性和状态
    closedmodenameencodingerrorsline_bufferingnewlinesreadable()writable()isatty()
  5. 其他文件方法
    close()detach()fileno()truncate()__next__()

使用这些方法时,应遵循以下最佳实践:

  • 始终使用with语句管理文件对象
  • 指定正确的文件编码
  • 处理文件操作异常
  • 逐行处理大文件
  • 使用合适的文件模式
  • 及时关闭文件(如果不使用with语句)

通过掌握这些文件方法和最佳实践,可以有效地处理各种文件操作任务,编写更加可靠和高效的Python程序。


发布网站:荣殿教程(zhangrongdian.com) 

作者:张荣殿 

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 03:51:02 HTTP/2.0 GET : https://f.mffb.com.cn/a/498638.html
  2. 运行时间 : 0.115051s [ 吞吐率:8.69req/s ] 内存消耗:5,083.73kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=81e97e66acfc74d955d4e87ad9407a9c
  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.000579s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000805s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000354s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000325s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000550s ]
  6. SELECT * FROM `set` [ RunTime:0.000283s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000574s ]
  8. SELECT * FROM `article` WHERE `id` = 498638 LIMIT 1 [ RunTime:0.000691s ]
  9. UPDATE `article` SET `lasttime` = 1783021862 WHERE `id` = 498638 [ RunTime:0.006129s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000305s ]
  11. SELECT * FROM `article` WHERE `id` < 498638 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000465s ]
  12. SELECT * FROM `article` WHERE `id` > 498638 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.005318s ]
  13. SELECT * FROM `article` WHERE `id` < 498638 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002687s ]
  14. SELECT * FROM `article` WHERE `id` < 498638 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.003566s ]
  15. SELECT * FROM `article` WHERE `id` < 498638 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.015826s ]
0.116695s