当前位置:首页>python>Python学习 | 06 Pythonic Iteration:Comprehension与更自然的循环写法

Python学习 | 06 Pythonic Iteration:Comprehension与更自然的循环写法

  • 2026-08-24 09:23:43
Python学习 | 06 Pythonic Iteration:Comprehension与更自然的循环写法

前五课,我们已经能够写出真正的 sequence-processing loop:

seq = ”ATGCGT”k = 3kmers = []for i in range(len(seq) - k + 1):    kmer = seq[i:i + k]    kmers.append(kmer)print(kmers)

这段代码完全正确,而且非常重要。

现在 Lesson 06 要做的不是推翻它,而是认识 Python 中一种极其常见的模式:

建立空容器for 遍历计算一个结果append 到容器

当逻辑足够简单时,Python 通常会把它写成 comprehension。

例如上面的 k-mer:

kmers = [    seq[i:i + k]    for i in range(len(seq) - k + 1)]kmers

这就是这一课的核心。

不过有一条原则要从一开始就明确:

Pythonic 不等于“代码越短越好”。

我们真正关心的是:

哪种写法最直接地表达这段代码想做什么。

1. List comprehension:把“循环 + 收集结果”写在一起

1.1 从普通 for 到 list comprehension

先看普通写法:

reads = [    ”ATGCGT”,    ”ATCC”,    ”GGGAAA”]lengths = []for read in reads:    lengths.append(len(read))print(lengths)

这里的逻辑其实只有一句话:

对每条 read 计算 len(read),把结果放进一个 list。

所以 Python 可以写:

lengths = [len(readfor read in reads]print(lengths)

基本结构是:

[    expression    for item in iterable]

也就是:

对 iterable 中的每个 item计算 expression收集到新的 list

假如想把reads全部变成大写:

reads = [”atgcgt”, ”atcc”, ”gggaaa”]

普通 for:

upper_reads = []for read in reads:    upper_reads.append(read.upper())print(upper_reads)

comprehension:

upper_reads = [read.upper() for read in reads]print(upper_reads)

所以你可以先把 list comprehension 理解成:

for + append

的一种紧凑表达。

1.2 和 R 的思维对照

对你来说,这个概念其实不会陌生。

R 中:

reads <- c(”ATGC”, ”GGAA”, ”ATCG”)nchar(reads)

可以直接得到每条 sequence 的长度,因为很多 R 函数本身就是 vectorized 的。

Python list:

reads = [”ATGC”, ”GGAA”, ”ATCG”]

不是 R vector,所以不能假定:

len(reads)

因为它问的是:

这个 list 有多少个元素?

要计算每个元素的长度:

[len(readfor read in reads]

2. 在 comprehension 中筛选元素

2.1 for ... if ...:只保留满足条件的对象

在 comprehension 末尾加入 if,可以只收集满足条件的元素。

reads = [    ”ATGCGT”,    ”ATGC”,    ”GGCCAATT”,    ”AT”,    ”CCGTA”]

只保留长度至少为 5 的 reads。

普通写法:

long_reads = []for read in reads:    if len(read) >= 5:        long_reads.append(read)print(long_reads)

comprehension:

long_reads = [    read    for read in reads    if len(read) >= 5]long_reads

结构是:

[    expression    for item in iterable    if condition]

阅读时不要从左到右机械翻译。

可以按照这个顺序理解:

for read in reads        ↓if len(read) >= 5        ↓保留 read

再比如过滤掉含 N 的 reads:

reads = [    ”ATGCGT”,    ”ATGCNT”,    ”GGCCAA”,    ”NNNNNN”]
valid_reads = [    read    for read in reads    if ”N” not in read]print(valid_reads)

2.2 筛选和转换可以同时进行

例如:

只处理没有 N 的 read,然后计算长度。

length = [    len(read)    for read in reads    if ”N” not in read]print(length)

3. 两种 if 不要混淆:筛选 vs if/else 转换

这是 list comprehension 最容易写乱的地方之一。

3.1 只有 if:表示筛选

numbers = [12345]

只保留偶数:

even_numbers = [    x    for x in numbers    if x % 2 == 0]print(even_numbers)

所以:

... for x in data if condition

表达的是:

filter

3.2 if ... else ...:每个元素都保留,但决定产生什么结果

例如给 read 打标签:

reads = [    ”ATGCGT”,    ”ATGC”,    ”GGCCAATT”]

如果长度至少为 5:pass,否则 short

labels = [    ”pass” if len(read) >=5 else ”short”    for read in reads]labels

筛选:

[    read    for read in reads    if len(read) >= 5]

而 conditional expression:

[    ”pass” if len(read) >=5 else ”short”    for read in reads]

因为:

”pass” if condition else ”short

本身就是一个完整的 expression。

类似:

如果条件成立,expression 的结果是 ”pass”否则结果是 ”short

4. 把 comprehension 用到 sequence algorithm

这一部分比拿 [x * 2 for x in numbers] 举例重要得多。

4.1 一行生成所有 k-mer

Lesson 05 我们写过:

seq = ”ATGCGT”k = 3kmers = []for i in range(len(seq) - k + 1):    kmer = seq[i:i+k]    kmers.append(kmer)print(kmers)

List comprehension 可以直接把每一个滑动窗口收集为 k-mer。

kmers = [    seq[i:i+k]    for i in range(len(seq) - k + 1)]print(kmers)

甚至可以写成一行:

kmers = [seq[i:i+k] for i in range(len(seq) - k + 1)]print(kmers)

4.2 找出所有 motif positions

Lesson 05:

seq = ”GATATATGCATATACTT”motif = ”ATAT”positions = []for i in range(len(seq) - len(motif) + 1):    if seq[i:i + len(motif)] == motif:        positions.append(i + 1)positions

Comprehension 可以收集所有满足 motif 匹配条件的位置。

positions = [    i + 1    for i in range(len(seq) - len(motif) + 1)    if seq[i:i+len(motif)] == motif]positions

4.3 什么时候 range() 仍然是正确选择?

上一课我们说:

for i, base in enumerate(seq):

通常比:

for i in range(len(seq)):    base = seq[i]

更自然。

但不要因此形成:

range(len(...)) 永远是不 Pythonic 的。

比如 k-mer:

seq[i:i + k]

我们真正需要的是:

每一个合法的 window start index

所以:

range(len(seq) - k + 1)

就是非常自然的写法。

我真正需要的是元素,还是位置?

如果只需要元素:

for read in reads:

需要:

index + element

使用:

enumerate()

需要:

一系列 window start positions

使用

range()

这才是 Pythonic iteration 真正应该建立的判断能力。

5. Dictionary 和 Set comprehension

Comprehension 不只可以创建 list。

Python 也提供:

list comprehensiondict comprehensionset comprehension

5.1 Dictionary comprehension:生成 key: value

例如:

sequences = {    ”seq1”: ”ATGCGT”,    ”seq2”: ”ATCC”,    ”seq3”: ”GGGAAA”}

我们想建立:

sequence ID → sequence length

普通写法:

lengths = {}for seq_id, seq in sequences.items():    lengths[seq_id] = len(seq)print(lengths)

Dictionary comprehension:

lengths = {    seq_id: len(seq)    for seq_id, seq in sequences.items()}print(lengths)

基本结构:

{    key_expression: value_expression    for item in iterable}

和 list comprehension 最大的区别只是:

list→ 收集 expressiondict→ 收集 key: value

还可以加入筛选。

例如:

只保存长度至少为 5 的 sequence。

long_sequences = {    seq_id: seq    for seq_id, seq in sequences.items()    if len(seq) >= 5}print(long_sequences)

5.2 Set comprehension:自动得到 unique elements

例如:

seq = ”ATGCGT”k = 2

生成所有 unique 2-mers:

unique_kmers = {    seq[i:i+k]    for i in range(len(seq) - k +1)}print(unique_kmers)

Set comprehension: {read for read in reads}

dictionary comprehension: {seq_id: seq for seq_id, seq in sequences.items()}

kmers = [”ATG”, ”TGC”, ”ATG”, ”GCG”, ”TGC”]unique_kmers = {kmer for kmer in kmers}print(unique_kmers)
不过如果你只是为了去重,set更加直接
set(kmers)

6. enumerate()、zip() 与 comprehension 怎么配合?

Lesson 05 已经认识了这两个工具。这一课主要解决“什么时候选哪个”。

6.1 enumerate():需要“位置 + 元素”

例如:

seq = ”ATGC”

想得到:

[    (0, ”A”),    (1, ”T”),    (2, ”G”),    (3, ”C”)]

可以:

positions = [    (i, base)    for i, base in enumerate(seq)]print(positions)

如果只想找到所有 "G" 的位置:

seq = ”ATGGC”g_positions = [    i    for i, base in enumerate(seq)    if base == ”G”]print(g_positions)
seq.find(”G”)

6.2 zip():需要“多个 iterable 按位置配对”

例如:

seq_ids = [”seq1”, ”seq2”, ”seq3”]sequences = [”ATGC”, ”GGAA”, ”ATCGT”]

可以建立 dictionary:

seq_dict = {    seq_id: seq    for seq_id, seq in zip(seq_ids, sequences)}print(seq_dict)

当然这里其实还有一个更直接的写法:

seq_dict = dict(zip(seq_ids, sequences))print(seq_dict)

可以先建立这张表:

你真正需要什么
更自然的工具
只需要元素
for item in data
元素 + index
enumerate(data)
多个 iterable 同时遍历
zip(a, b)
自己生成整数范围
range(...)
sequence window 的起始位置
range(...)

7. Comprehension 不等于 vectorization

这一点我想专门强调,因为对 R 用户非常重要。

你可能看到

lengths = [len(readfor read in reads]

觉得:

这是不是 Python 的 vectorized operation?

不是。

List comprehension 本质上仍然是在逐个迭代元素。

概念上它仍然类似:

lengths = []for read in reads:    lengths.append(len(read))

只是 Python 提供了一种更适合表达:

遍历 → 转换 → 收集

的语法。

真正到了 NumPy,我们才会看到另一种完全不同的思维:

import numpy as npx = np.array([123])x * 2

这里才更加接近你熟悉的 R vectorization。

因此目前最好区分:

Python list comprehension→ iterationNumPy array operation→ vectorization

8. 什么时候应该用 comprehension,什么时候继续写普通 for?

这是这一课真正比“会写语法”更重要的地方。

适合 comprehension:一个简单的转换

例如:

lengths = [len(readfor read in reads]

非常清楚:

每条 read → length

valid_reads = [    read    for read in reads    if ”N” not in read]

非常自然:

从 reads 中选出不含 N 的。

lengths = [    len(read)    for read in reads    if ”N” not in read]

但是下面这些情况,通常继续写普通 for 更好。

例如:

for read in reads:    gc_count = read.count(”G”) + read.count(”C”)    gc_content = gc_count / len(read)    if gc_content > 0.6:        print(read, gc_content)

硬压成一行不会更 Pythonic,只会更难读。


例如 nucleotide counting:

counts = {    ”A”: 0,    ”C”: 0,    ”G”: 0,    ”T”: 0}for base in seq:    counts[base] += 1

这就是很好的普通 loop。

不应该为了“所有循环都改成 comprehension”而强行改写。

后面我们会学:

Counter(seq)

那是因为已经有一个更合适的数据结构工具,不是因为 for 不好。


例如:

for read in reads:    print(read)

不要写:

[print(readfor read in reads]

虽然 Python 可以执行,但这不是好的用法。

为什么?

因为 comprehension 的语义应该是:

创建一个新的 collection。

而这里我们的真实目的只是:print

并不想创建 list。

普通 for 反而最清楚。


例如:

for base in seq:    if base == ”N”:        print(”Invalid sequence”)        break

普通 for 就非常自然。

不要为了省几行代码把控制逻辑塞进复杂 expression。


所以最终可以记成:

简单的transform / filter / collect        ↓comprehension复杂的logic / state / side effect / control flow        ↓普通 for

9. 一个综合例子:从 reads 到 QC 后的 k-mers

现在把前六课连起来。

给定:

reads = [    ”ATGCGT”,    ”ATGCNT”,    ”GGCCAA”,    ”AT”,    ”ATGCGT”]

我们的第一步是:

去掉含 N 的 reads,并且只保留长度至少为 3 的 reads。

clean_reads = [    read    for read in reads    if ”N” not in read and len(read) >= 3]print(clean_reads)

如果只是想得到 unique reads:

unique_reads = set(clean_reads)unique_reads

然后,对于一条 sequence:

seq = ”ATGCGT”k=3kmers = [    seq[i:i+k]    for i in range(len(seq) - k + 1)]kmers

再得到 unique k-mers:

unique_kmers = set(kmers)unique_kmers

10. 本课练习

这一课我仍然只留几道真正值得写的。

Exercise A|普通 for → comprehension

给定:

reads = [    ”ATGCGT”,    ”ATCC”,    ”GGGAAA”,    ”A”]

先用普通 for 得到每条 read 的长度,然后改写为list comprehension

read_len = []for read in reads:    read_len.append(len(read))read_len
read_len = [    len(read)    for read in reads]read_len

Exercise B|筛选 reads

仍然使用:

reads = [    ”ATGCGT”,    ”ATGCNT”,    ”GGCCAA”,    ”NNNNNN”,    ”AT”]

用一个 list comprehension,只保留:

不含 N 并且 长度 >= 5

clean_reads = [    read    for read in reads    if ”N” not in read and len(read) >= 5]clean_reads

Exercise C|if 筛选和 if/else 转换

给定:

reads = [    ”ATGCGT”,    ”AT”,    ”GGCCAA”]

分别写两个 comprehension。

第一个:

只保留长度 >= 5 的 read

第二个:

每条 read 都保留,长度 >= 5 → "pass" 否则 → "short"

然后解释:

为什么两个 comprehension 中 if 的位置不同?

[    read    for read in reads    if len(read) >= 5]
[    ”pass” if len(read) >= 5 else ”short”    for read in reads]

因为第一个是筛选read,第二个只是定义label,没有对read进行筛选。并且"pass" if len(read) >= 5 else "short"本身就是一个expression,

Exercise D|k-mer composition

给定:

seq = ”CAATCCAAC”k = 5

使用 list comprehension 生成所有 5-mer。

不要先运行。

先回答:

sequence length = ? k = 5

应该产生多少个 k-mer?

使用:

n - k + 1

自己预测结果数量。

然后再写代码。

len(seq) - k + 1
[    seq[i:i+k]    for i in range(len(seq) - k + 1)]

Exercise E|Motif positions

给定:

seq = ”GATATATGCATATACTT”motif = ”ATAT”

使用 list comprehension 找到所有:

1-based motif positions

要求最终得到一个:

positions = [...]

而不是直接 print()。

positions = [    i + 1    for i in range(len(seq) - len(motif) + 1)    if seq[i:i+len(motif)] == motif]positions

Exercise F|Dictionary comprehension

给定:

sequences = {    ”seq1”: ”ATGCGT”,    ”seq2”: ”ATCC”,    ”seq3”: ”GGGAAA”}

建立:

lengths

让结果表示:

seq_id → sequence length

然后进一步只保留:

length >= 5

的sequence。

seq_len = {    seq_id: len(seq)    for seq_id, seq in sequences.items()}seq_len
long_seq = {    seq_id:seq    for seq_id, seq in sequences.items()    if len(seq) >= 5}long_seq

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-24 11:24:42 HTTP/2.0 GET : https://f.mffb.com.cn/a/512068.html
  2. 运行时间 : 0.149081s [ 吞吐率:6.71req/s ] 内存消耗:4,633.96kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=fb07aed91ab6995cb5cbeb5dd6640225
  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.000773s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000909s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000312s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000253s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000503s ]
  6. SELECT * FROM `set` [ RunTime:0.000200s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000507s ]
  8. SELECT * FROM `article` WHERE `id` = 512068 LIMIT 1 [ RunTime:0.000484s ]
  9. UPDATE `article` SET `lasttime` = 1787541882 WHERE `id` = 512068 [ RunTime:0.012180s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.006027s ]
  11. SELECT * FROM `article` WHERE `id` < 512068 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000514s ]
  12. SELECT * FROM `article` WHERE `id` > 512068 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000384s ]
  13. SELECT * FROM `article` WHERE `id` < 512068 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.005737s ]
  14. SELECT * FROM `article` WHERE `id` < 512068 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.020727s ]
  15. SELECT * FROM `article` WHERE `id` < 512068 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.021069s ]
0.152797s