当前位置:首页>python>Python学习 | 08 文件与路径

Python学习 | 08 文件与路径

  • 2026-08-26 18:11:50
Python学习 | 08 文件与路径

前面七课,我们处理的数据基本都直接写在 Python 代码里:

seq = ”ATGCGT”reads = [”ATGC”, ”GGAA”, ”CCGT”]

然后再把它们交给 function:

gc_content(seq)generate_kmers(seq, 3)find_motif(seq, motif)

但真正做生物信息学时,数据当然不会这样存在。

你面对的是:

genome.fareads.fastqvariants.vcfannotation.gtfsample.bed

所以从 Lesson 08 开始,我们要把前面学到的 Python 世界和磁盘上的真实数据连接起来。

这一课最重要的流程是:

文件路径   ↓open   ↓file object   ↓读取 text   ↓解析 text   ↓Python object   ↓分析   ↓写回文件

也就是说,今天真正学习的不是几个 open() 方法,而是:

怎样让数据从磁盘进入 Python,再经过处理后回到磁盘。

这会直接为 Lesson 09 的 FASTA / FASTQ parser 做准备。


1. open() 与 with:Python 怎样访问文件

1.1 从一个最简单的文本文件开始

假设当前目录中有:sequence.txt

内容是:ATGCGTACGT

Python 可以:

with open(”sequence.txt”, ”r”) as f:    sequence = f.read()

现在:

sequence

可能得到:

'ATGCGTACGT\n'

这里第一次出现几个新东西:

”sequence.txt”  → 文件路径”r”             → read modeopen(...)       → 打开文件f               → file objectf.read()        → 读取文件内容

其中真正需要建立的概念是:

open() 并不是“把文件变成字符串”。

而是首先创建一个file object,通过这个对象和磁盘上的文件交互。

可以想成:

sequence.txt     ↑     │     ffile object

然后:

f.read()

才把其中的数据读取出来。


1.2 为什么总是推荐 with open(...) as f

你当然可以写:

f = open(”sequence.txt”, ”r”)sequence = f.read()f.close()

但是更推荐:

with open(”sequence.txt”, ”r”) as f:    sequence = f.read()

原因是:

离开 with 代码块后,Python 会自动关闭文件。

也就是说:

with open(...) as f:    ...

负责:打开文件→使用文件→自动关闭。

这叫context manager

现在不需要深入研究它的实现机制。

对于你目前来说,直接形成习惯:

with open(...) as f:    ...

就很好。

尤其科研代码中,一个脚本可能会处理成千上万个文件,忘记关闭文件并不是一个值得保留的习惯。


1.3 "r"、"w"、"a":你准备怎样使用文件?

最常见的三个 mode:

r → readw → writea → append
with open(”sequence.txt”, ”r”) as f:    ...

实际上 "r" 是默认值,所以:

with open(”sequence.txt”) as f:    ...

也可以。

但初期写出来有助于理解。


with open(”output.txt”, ”w”) as f:    ...

非常重要:

"w" 如果发现文件已经存在,会覆盖原文件。

例如原来output.txt里面有 1000 行结果。

执行:

with open(”output.txt”, ”w”) as f:    f.write(”hello”)

原来的内容就没有了。

科研分析里一定要对这一点有意识。


with open(”log.txt”, ”a”) as f:    ...

表示:保留旧内容 + 把新内容加到最后。

不过数据分析结果是否适合用 "a",取决于任务本身,不应该为了“不覆盖”就全部使用 append。


2. 读取文件:整个读取,还是逐行处理?

这是 genomics 中非常重要的区别。

假设sequences.txt内容:

ATGCGTGGCAATTTAACC

有几种读取方式。

2.1 read():整个文件一次读进来

with open(”sequences.txt”, ”r”) as f:    text = f.read()

得到类似:

'ATGCGT\nGGCAAT\nTTAACC\n'

注意:\n 代表 newline。

也就是说磁盘中看起来是:

ATGCGT GGCAAT TTAACC

Python string 实际可以理解成:

ATGCGT\nGGCAAT\nTTAACC\n

这就是为什么:

text.split(”\n”)

可以把它拆开。


如果文件很小:几KB,几MB,整个读入内存通常没有问题。

但你的研究以后很可能面对:

5 GB FASTA 30 GB FASTQ 100 GB sequencing data

这时候f.read()的思路就值得警惕。 因为它意味着:

把整个文件内容一次加载到内存。


2.2 for line in f:逐行处理

对大文件,更重要的是:

with open(”sequence.txt”, ”r”) as f:    for line in f:        print(line)

这里的思维完全不同:

文件 ↓读取第 1 行 → 处理 ↓读取第 2 行 → 处理 ↓读取第 3 行 → 处理 ↓...

而不是:

整个文件   ↓全部进入内存   ↓再处理

这其实是你以后处理 FASTA / FASTQ 时最重要的编程习惯之一。

对于 genomics:

能逐条处理,就不要默认把整个大文件读进内存。


2.3 readline() 和 readlines()

你也会在别人代码里看到:

f.readline()

它读取一行。

例如:

with open(”sequences.txt”) as f:    first_line = f.readline()

而:

f.readlines()

会把所有行读取成一个 list:

[    ”ATGCGT\n”,    ”GGCAAT\n”,    ”TTAACC\n”]

所以可以简单理解:

read()→ 整个文件 → 一个 stringreadline()→ 一次一行 → 一个 stringreadlines()→ 所有行 → 一个 listfor line in f→ 一行一行迭代

对于你后面的大型 genomics 文件,我最希望你习惯的是:

for line in f:

而不是:

f.readlines()

因为后者仍然会一次把所有行放进内存。


3. 文本解析:strip() 和 split() 才是真正的主角

打开文件只是第一步。

真正的数据处理往往发生在:

raw textparsestructured data

这个过程中。


3.1 为什么经常看到 line.strip()

假设文件:

ATGCGTGGCAATTTAACC

执行:

with open(”sequences.txt”) as f:    for line in f:        print(repr(line))

每一行后面有:\n。因此,经常写:

line = line.strip()
with open(”sequences.txt”) as f:    for line in f:        line = line.strip()        print(repr(line))

前面 Lesson 02 已经认识过 strip()。

现在终于看到它为什么在真实文件处理中如此常见。

一个非常典型的模式就是:

with open(”sequences.txt”) as f:    for line in f:        line = line.strip()        if line == ””:            continue        print(line)

意思是:

逐行读取去掉换行等首尾空白跳过空行处理真正的数据

3.2 split():把一行文本拆成字段

真实文件通常不是:

ATGCGT

这么简单。

比如一个 tab-separated 文件:

seq1    ATGCGT seq2    GGCAAT seq3    TTAACC

这里实际上是:

seq1\tATGCGT seq2\tGGCAAT seq3\tTTAACC

\t 表示 tab。

逐行读取:

with open(”sequences.tsv”) as f:    for line in f:        line = line.strip()        seq_id, seq = line.split(”\t”)        print(seq_id, seq)

对于:

seq1    ATGCGT

执行:

line.split(”\t”)

得到:

[”seq1”, ”ATGCGT”]

然后利用 Lesson 03 学过的 unpacking:

seq_id, seq = line.split(”\t”)

于是:

seq_id → ”seq1”seq    → ”ATGCGT”

到这里你应该会发现:

前面那些看起来零散的 Python 基础,现在开始真正组合起来了。

string+split+list+unpacking+for+function+file IO

3.3 文件中的数字首先也是 string

这是 R 用户尤其值得注意的一点。

假设文件:

seq1    ATGCGT    6seq2    GGCAAT    6

读取:

seq_id, seq, length = line.strip().split(”\t”)

此时length不是6:这个integer,而是:"6"。也就是type(length)得到str。

如果后面需要数学计算:

length = int(length)

这正好回到 Lesson 01:

文件本身只保存文本 ↓ Python 读取成 str ↓ 根据数据含义做类型转换

以后读:

VCF BED GFF

时你会不断遇到这个过程。


4. 写文件:分析结果怎样保存下来?

读取:f.read() 写入:f.write()

例如:

with open(”output.txt”, ”w”) as f:    f.write(”ATGCGT”)

文件就会包含:

ATGCGT

4.1 write()不会自动加换行

假设:

with open(”output.txt”, ”w”) as f:    f.write(”seq1”)    f.write(”seq2”)

结果是:

seq1seq2

如果需要换行:

with open(”output.txt”, ”w”) as f:    f.write(”seq1\n”)    f.write(”seq2\n”)

得到:

seq1seq2

这一点非常简单,但也是文件输出最常见的小错误之一。


4.2 输出 tab-separated table

例如:

seq_id = ”seq1”seq = ”ATGCGT”length = len(seq)

可以写:

with open(”output.tsv”, ”w”) as f:    f.write(f”{seq_id}\t{seq}\t{length}\n”)

结果:

seq1    ATGCGT    6

这里第一次真正把前面学过的:

f-string+\t+\n+write

连接起来。


4.3print(..., file=f) 也可以写文件

Python 还有一种非常方便的写法:

with open(”output.txt”, ”w”) as f:    print(”seq1”, file=f)    print(”seq2”, file=f)

得到:

seq1seq2

因为 print() 默认自动换行。

甚至:

with open(”output.tsv”, ”w”) as f:    print(seq_id, seq, length, sep=”\t”, file=f)

也可以生成 tab-separated 行。

所以:

f.write(...)

和:

print(..., file=f)

都很常见。

初期你可以这样理解:

write→ 对具体写入的字符串控制更直接print(..., file=f)→ 输出人类可读的文本非常方便

5. pathlib:不要靠字符串拼文件路径

到目前为止我们一直写:

”sequence.txt”

但真实项目可能是:

project/├── data/│   ├── raw/│   │   └── reads.fastq│   └── genome.fa├── results/└── scripts/

过去常见的写法可能是:

filename = ”reads.fastq”path = ”data/raw” + filename

现代 Python 更推荐:

from pathlib import Path

然后:

path = Path(”data”) / ”raw” / ”reads.fastq”print(path)

这也是这节课非常值得养成的习惯。


5.1 Path 表示一个路径

from pathlib import Pathpath = Path(”data/genome.fa”)type(path)

现在 path 不是普通 string。

它表示:

文件系统中的一个路径。

可以:

path.name
path.stem
path.suffix
path.parent

非常适合科研脚本。


5.2 / 在 Path 中表示拼接路径

这是第一次看到/不是除法。

例如:

data_dir = Path(”data”)path = data_dir / ”genome.fa”print(path)

如果:

sample = ”sample01”

可以:

path = Path(”results”) / f”{sample}.txt”path

以后批量处理几十个 sample 时非常自然。


5.3 判断文件是否存在

path.exists()

返回True或False。

判断它是否是文件:

path.is_file()

判断是否为目录。

from pathlib import Pathpath = Path(”data/genome.fa”)if not path.exists():    raise FileNotFoundError(f”File not found: {path}”)

5.4 当前工作目录:一个非常重要的概念

运行:

Path.cwd()

可以查看:

current working directory

也就是:

Python 当前把哪里当作“当前位置”。

假设:

Path.cwd()

是:

/home/user/project

那么:

Path(”data/genome.fa”)

实际指向:

/home/user/project/data/genome.fa

所以 relative path:

data/genome.fa

本质上依赖:

current working directory

这也是为什么初学 Python 时经常会遇到:

FileNotFoundError

明明“文件就在那个文件夹里”。

问题往往不是文件不存在,而是:

Python 当前工作的目录不是你以为的目录。

遇到这种情况,第一件事应该是:

from pathlib import Pathprint(Path.cwd())

确认自己究竟在哪里。

这个习惯以后非常有用。


6. 把前七课全部串起来:写一个真正的 sequence 文件处理程序

现在假设:

sequences.tsv

内容:

seq1	ATGCGTseq2	GGCCAATTseq3	ATATAT

我们的目标是:

  1. 逐行读取
  2. 得到 sequence ID 和 sequence
  3. 计算 length
  4. 计算 GC content
  5. 保存到结果文件

先复用 Lesson 07:

def gc_content(seq):    if len(seq) == 0:        raise ValueError(”Sequence is empty”)        gc = seq.count(”G”) + seq.count(”C”)

然后:

from pathlib import Pathdef analyze_sequences(input_path, output_path):    input_path = Path(input_path)    output_path = Path(output_path)    with open(input_path, ”r”) as infile, open(output_path, ”w”) as outfile:        outfile.write(”seq_id\tlength\tgc_content\n”)        for line in infile:            line = line.strip()            if line == ””:                continue            seq_id, seq = line.split(”\t”)            length = len(seq)            gc = gc_content(seq)            outfile.write(                f”{seq_id}\t{length}\t{gc}\n”            )

调用:

analyze_sequences(    ”sequences.tsv”,    ”sequence_summary.tsv”)

得到:

seq_id    length    gc_contentseq1      6         0.5seq2      8         0.5seq3      6         0.0

这段代码值得认真看,因为它已经不是“Python 语法练习”了。

它拥有一个真正科研脚本的雏形:

input file    ↓read    ↓parse    ↓function    ↓analysis    ↓output file

而且几乎所有东西你都已经学过。


String

line.strip()line.split(”\t”)

Tuple unpacking

seq_id, seq = ...

Condition

if line == ””:    continue

Loop

for line in infile:

Function

gc_content(seq)

Exception

raise ValueError(...)

f-string

f”{seq_id}\t{length}\t{gc}\n”

File IO

with open(...)

Path

Path(...)

这就是为什么前几课一直强调:

不需要孤立地背方法。

真正重要的是知道这些工具什么时候组合起来。


科研文件不一定永远完美。

比如:

seq1	ATGCGTseq2	GGCCAATTbad_lineseq3	ATATAT

如果直接:

seq_id, seq = line.split(”\t”)

处理bad_line时就会报错。

我们现在已经有能力主动给出更清楚的信息:

def read_sequences(path):    sequences = {}    with open(path) as f:        for line_number, line in enumerate(f, start=1):            line = line.strip()            if line == ””:                continue            fields = line.split(”\t”)            if len(fields) != 2:                raise ValueError(                    f”Invalid format at line {line_number}”                )            seq_id, seq = fields            sequences[seq_id] = seq    return sequences

这里有一个很值得注意的新组合:

for line_number, line in enumerate(f, start=1):

Lesson 05 的 enumerate() 现在不再是在 list 上做练习,而是在真正的文件上发挥作用。

如果第 37 行坏掉:

ValueError: Invalid format at line 37

显然比:

ValueError: not enough values to unpack

更适合科研程序。

因为你马上知道应该去检查输入文件的哪一行。


你可以暂时这样建立迁移关系:

R
Python
readLines()f.read()
 / for line in f
writeLines()f.write()
 / print(..., file=f)
strsplit().split()
trimws().strip()
file.exists()Path.exists()
getwd()Path.cwd()
file.path()Path(...) / ...

但有一个区别很重要。

R 用户很容易直接想到:

read.delim()read.table()readr::read_tsv()

然后整个文件变成 data frame。

Python 后面当然也有:

pandas.read_csv()

但我们现在故意先不使用 Pandas。

因为对于:

FASTAFASTQVCFGFFSAM

理解:

文件→ line→ field→ parsing

本身就是很重要的能力。

尤其你后面需要写 genome assembly 和 sequence-processing code,这种思维比“会调用 read_csv()”重要得多。


假设reads.fastq有40GB。不要默认:

text = f.read()lines = f.readlines()

更应该想到:

with open(path) as f:    for line in f:        ...

也就是data streaming的思维。

下一课我们就会进一步把它升级为:

def read_fasta(path):    ...    yield ...

也就是:

file iteration+parser+generator

从而可以做到:

for seq_id, seq in read_fasta(”genome.fa”):    ...

即使文件非常大,也不必一次全部加载到内存。

不过generator 是 Lesson 09的内容,这一课先把:

pathopenfile objectlinestripsplitwrite

真正掌握好。


Exercises

Exercise A|预测 read() 的结果

假设文件:seq.txt

内容:

ATGCGT GGCAAT

代码:

with open(”seq.txt”) as f:    x = f.read()print(repr(x))

假设文件最后也有一个正常换行符。

问:

x 是什么?type(x) 是什么? len(x) 是多少?

x是:ATGCGT\nGGCAAT\n。type(x)是str,len(x)是14。


Exercise B|逐行读取并过滤空行

假设:read.txt。

内容:

ATGCGT GGCAAT ATNNGC TTAACC

要求读取所有非空行,并且过滤掉含 "N" 的 sequence。

最后得到:

[    ”ATGCGT”,    ”GGCAAT”,    ”TTAACC”]
def read_reads(infile):    sequences = []    with open(infile, ”r”) as f:        for line in f:            read = line.strip()            if read == ””:                continue            if ”N” in read:                continue            sequences.append(read)    return sequencesread_reads(”reads.txt”)
reads = []with open(”reads.txt”) as f:    for line in f:        read = line.strip()        if read == ””:            continue        if ”N” in read:            continue        reads.append(read)
reads = []with open(”reads.txt”) as f:    for line in f:        read = line.strip()        if read != ”” and ”N” not in read:            reads.append(read)

两种都可以。

第一种对复杂数据清洗通常更容易读。


Exercise C|用 Path 构建 sample 路径

给定:sample = "sample01"

希望建立:project/data/sample01/reads.fastq

要求使用 pathlib

然后分别得到:

文件名 suffix parent directory

sample = ”sample01”from pathlib import Pathfile = (    Path(”project”) / ”data” / sample / ”reads.fastq”)print(file.name)print(file.suffix)print(file.parent)

Exercise D|解析一个 TSV 文件

假设:sequences.tsv

内容:

seq1	ATGCGTseq2	GGGAAAseq3	ATATGC

写:def read_sequences(path):

要求返回:

{    ”seq1”: ”ATGCGT”,    ”seq2”: ”GGGAAA”,    ”seq3”: ”ATATGC”}
def read_sequences(path):    sequences  = {}    with open(path, ”r”) as f:        for line in f:            line = line.strip()            if line == ””:                continue            seq_id, seq  = line.split(”\t”)            sequences[seq_id] = seq    return sequencesread_sequences(”sequences.tsv”)

Exercise E|给 parser 加上错误检查

继续使用:read_sequences()

现在要求:

  1. 忽略空行
  2. 每一行必须恰好有两个 tab-separated fields
  3. sequence 只能包含:
    >A C G T N
  4. 如果格式错误,要告诉你是哪一行
def read_sequences(path):    sequences  = {}    valid_bases = set(”ATCGN”)    with open(path, ”r”) as f:        for line_number, line in enumerate(f, start=1):            line = line.strip()            if line == ””:                continue            fields = line.split(”\t”)            if len(fields) != 2:                raise ValueError(f”Invalid format at {line_number}”)            seq_id, seq = fields            if not set(seq) <= valid_bases:                raise ValueError(f”Invalid sequence at {line_number}”)            sequences[seq_id] = seq    return sequencesread_sequences(”sequences.tsv”)

Exercise F|综合题:生成 sequence summary

这是本课最值得完整写一遍的题。

输入:sequences.tsv

seq1	ATGCGTseq2	GGGAAAseq3	ATATGCseq4	CCCGGG

写:def summarize_sequences(input_path, output_path):

生成summary.tsv

要求内容:

seq_id	length	gc_contentseq1	6	0.5seq2	6	0.5seq3	6	0.3333333333333333seq4	6	1.0

要求复用:gc_content()

而不是在主函数中重新写一遍 GC 计算逻辑。

from pathlib import Pathdef gc_content(seq):    if len(seq) == 0:        raise ValueError(”Sequence is empty”)    gc = seq.count(”G”) + seq.count(”C”)    return gc / len(seq)def summarize_sequences(input_path, output_path):    input_path = Path(input_path)    output_path = Path(output_path)    if not input_path.exists():        raise FileNotFoundError(f”Input file not found: {input_path}”)    with open(input_path,”r”) as infile, open(output_path,”w”) as outfile:        outfile.write(”seq_id\tlength\tgc_content\n”)        for line_number, line in enumerate(infile, start=1):            line = line.strip()            if line == ””:                continue            fields = line.split(”\t”)            if len(fields) != 2:                raise ValueError(f”Invalid format at {line_number}”)            seq_id, seq = fields            length = len(seq)            gc = gc_content(seq)            outfile.write(f”{seq_id}\t{length}\t{gc}\n”)summarize_sequences(”sequences.tsv”, ”summary.tsv”)

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-26 20:04:02 HTTP/2.0 GET : https://f.mffb.com.cn/a/512275.html
  2. 运行时间 : 0.177922s [ 吞吐率:5.62req/s ] 内存消耗:4,649.44kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=da5940b2c7037677b56233cb6dbf91be
  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.000934s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001560s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000758s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000784s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001352s ]
  6. SELECT * FROM `set` [ RunTime:0.000599s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001475s ]
  8. SELECT * FROM `article` WHERE `id` = 512275 LIMIT 1 [ RunTime:0.001200s ]
  9. UPDATE `article` SET `lasttime` = 1787745842 WHERE `id` = 512275 [ RunTime:0.069456s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000737s ]
  11. SELECT * FROM `article` WHERE `id` < 512275 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001180s ]
  12. SELECT * FROM `article` WHERE `id` > 512275 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001151s ]
  13. SELECT * FROM `article` WHERE `id` < 512275 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001839s ]
  14. SELECT * FROM `article` WHERE `id` < 512275 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002330s ]
  15. SELECT * FROM `article` WHERE `id` < 512275 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.005108s ]
0.181768s