当前位置:首页>python>Python(二十五) 推导式详解

Python(二十五) 推导式详解

  • 2026-08-18 23:10:47
Python(二十五) 推导式详解
Python(二十五) 列表、字典、集合推导式详解
1. 什么是推导式

推导式是 Python 中一种非常常用的语法。

它可以用简洁的代码,根据已有数据快速生成新的数据。

通俗地说:

推导式就是把 for 循环生成数据的过程,压缩成一行来写。

例如,我们想生成一个列表,里面保存 1 到 5 的平方。

普通写法:

nums = []
for x inrange(16):
    nums.append(x * x)
print(nums)

输出:

[1491625]

使用列表推导式:

nums = [x * x for x inrange(16)]
print(nums)

输出:

[1491625]

两段代码结果一样。

推导式的好处是:

1.
写法简洁。
2.
逻辑清楚。
3.
常用于生成列表、字典、集合。
2. 推导式有哪些类型

Python 中常见的推导式主要有三种:

类型
写法
生成结果
列表推导式
[表达式 for 变量 in 可迭代对象]
list 列表
字典推导式
{键表达式: 值表达式 for 变量 in 可迭代对象}
dict 字典
集合推导式
{表达式 for 变量 in 可迭代对象}
set 集合

另外还有一种很像推导式的写法,叫生成器表达式:

(表达式 for 变量 in 可迭代对象)

它不是元组推导式,而是生成器表达式。

本篇重点讲:

1.
列表推导式
2.
字典推导式
3.
集合推导式
3. 先理解几个基础概念
3.1 什么是可迭代对象

可迭代对象简单理解就是:可以被 for 循环遍历的数据。

常见可迭代对象:

list# 列表
tuple# 元组
dict# 字典
set# 集合
str# 字符串
range# range 对象

例如:

for x in [123]:
print(x)

列表可以被 for 循环遍历,所以列表是可迭代对象。

再比如:

for ch in"abc":
print(ch)

字符串也可以被遍历,所以字符串也是可迭代对象。

3.2 什么是表达式

表达式就是可以计算出结果的代码。

例如:

x
x * 2
x + 10
x.upper()
str(x)

这些都可以作为推导式中的表达式。

3.3 推导式的基本思路

推导式一般可以按下面的顺序理解:

从一个可迭代对象中,依次取出元素,
对元素进行处理,
再把处理结果放入新的列表、字典或集合中。
4. 列表推导式

列表推导式用于快速创建列表。

4.1 基本语法
[表达式 for 变量 in 可迭代对象]

例如:

nums = [x for x inrange(16)]
print(nums)

输出:

[12345]

这段代码可以拆成普通循环:

nums = []
for x inrange(16):
    nums.append(x)
print(nums)
4.2 生成数字列表
nums = [x for x inrange(10)]
print(nums)

输出:

[0123456789]
4.3 对元素进行计算

生成 1 到 5 的平方:

squares = [x * x for x inrange(16)]
print(squares)

输出:

[1491625]

普通循环写法:

squares = []
for x inrange(16):
    squares.append(x * x)
print(squares)
4.4 对字符串进行处理

把所有单词转换成大写:

words = ["python""java""c++"]
result = [word.upper() for word in words]
print(result)

输出:

['PYTHON''JAVA''C++']

去掉字符串两边的空格:

names = [" 张三 "" 李四""王五 "]
result = [name.strip() for name in names]
print(result)

输出:

['张三''李四''王五']
4.5 加上筛选条件

语法:

[表达式 for 变量 in 可迭代对象 if 条件]

筛选偶数:

nums = [123456]
evens = [x for x in nums if x % 2 == 0]
print(evens)

输出:

[246]

普通循环写法:

nums = [123456]
evens = []
for x in nums:
if x % 2 == 0:
        evens.append(x)
print(evens)
4.6 筛选长度大于 3 的字符串
words = ["hi""python""java""ok"]
result = [word for word in words iflen(word) > 3]
print(result)

输出:

['python''java']
4.7 多个筛选条件

筛选大于 10 且是偶数的数字:

nums = [5812152023]
result = [x for x in nums if x > 10if x % 2 == 0]
print(result)

输出:

[1220]

也可以写成:

nums = [5812152023]
result = [x for x in nums if x > 10and x % 2 == 0]
print(result)

输出:

[1220]
4.8 使用 if...else

如果需要根据条件给出不同结果,可以使用 if...else

语法:

[值1if 条件 else 值2for 变量 in 可迭代对象]

例如,把偶数标记为 "偶数",奇数标记为 "奇数"

nums = [12345]
result = ["偶数"if x % 2 == 0else"奇数"for x in nums]
print(result)

输出:

['奇数''偶数''奇数''偶数''奇数']

再比如,及格显示 "通过",不及格显示 "不通过"

scores = [90587645]
result = ["通过"if score >= 60else"不通过"for score in scores]
print(result)

输出:

['通过''不通过''通过''不通过']
4.9 if 筛选和 if...else 的区别

这两个写法很容易混淆。

写法一:只筛选
[x for x in nums if x > 0]

意思是:

只保留大于 0 的 x。
写法二:二选一处理
[x if x > 0else0for x in nums]

意思是:

如果 x 大于 0,就保留 x;
否则使用 0。

示例:

nums = [-2, -1012]
result1 = [x for x in nums if x > 0]
result2 = [x if x > 0else0for x in nums]
print(result1)
print(result2)

输出:

[12]
[00012]

区别总结:

写法
含义
结果数量是否可能变少
[x for x in nums if 条件]
筛选数据
可能变少
[值1 if 条件 else 值2 for x in nums]
对每个数据做二选一处理
数量不变
4.10 嵌套循环列表推导式

列表推导式中可以写多个 for

例如,生成两个列表元素的所有组合:

colors = ["红""蓝"]
sizes = ["S""M""L"]
result = [(color, size) for color in colors for size in sizes]
print(result)

输出:

[('红''S'), ('红''M'), ('红''L'), ('蓝''S'), ('蓝''M'), ('蓝''L')]

等价于:

colors = ["红""蓝"]
sizes = ["S""M""L"]
result = []
for color in colors:
for size in sizes:
        result.append((color, size))
print(result)

推导式中的 for 顺序和普通循环顺序一致。

[(color, size) for color in colors for size in sizes]

对应:

for color in colors:
for size in sizes:
        ...
4.11 展平二维列表

把二维列表变成一维列表:

matrix = [
    [123],
    [456],
    [789]
]
result = [num for row in matrix for num in row]
print(result)

输出:

[123456789]

等价于:

matrix = [
    [123],
    [456],
    [789]
]
result = []
for row in matrix:
for num in row:
        result.append(num)
print(result)
4.12 嵌套循环加条件

生成所有乘积大于 10 的组合:

a = [1234]
b = [345]
result = [(x, y) for x in a for y in b if x * y > 10]
print(result)

输出:

[(34), (35), (43), (44), (45)]
4.13 配合 enumerate()

enumerate() 可以同时得到下标和元素。

names = ["张三""李四""王五"]
result = [f"{index}{name}"for index, name inenumerate(names)]
print(result)

输出:

['0: 张三''1: 李四''2: 王五']

如果希望编号从 1 开始:

names = ["张三""李四""王五"]
result = [f"{index}{name}"for index, name inenumerate(names, start=1)]
print(result)

输出:

['1: 张三''2: 李四''3: 王五']
4.14 配合 zip()

zip() 可以把多个可迭代对象中对应位置的元素组合起来。

names = ["张三""李四""王五"]
scores = [908578]
result = [f"{name}{score}"for name, score inzip(names, scores)]
print(result)

输出:

['张三: 90''李四: 85''王五: 78']
5. 字典推导式

字典推导式用于快速创建字典。

5.1 基本语法
{键表达式: 值表达式 for 变量 in 可迭代对象}

例如,创建数字和平方的对应关系:

squares = {x: x * x for x inrange(16)}
print(squares)

输出:

{112439416525}

普通循环写法:

squares = {}
for x inrange(16):
    squares[x] = x * x
print(squares)
5.2 从两个列表创建字典
names = ["张三""李四""王五"]
scores = [908578]
result = {name: score for name, score inzip(names, scores)}
print(result)

输出:

{'张三'90'李四'85'王五'78}

这里 zip(names, scores) 会依次产生:

("张三"90)
("李四"85)
("王五"78)
5.3 遍历字典创建新字典

如果要遍历字典的键和值,一般使用 .items()

scores = {"张三"90"李四"85"王五"78}
result = {name: score + 5for name, score in scores.items()}
print(result)

输出:

{'张三'95'李四'90'王五'83}
5.4 筛选字典中的数据

筛选成绩大于等于 80 的学生:

scores = {"张三"90"李四"58"王五"78"赵六"88}
passed = {name: score for name, score in scores.items() if score >= 80}
print(passed)

输出:

{'张三'90'赵六'88}

普通循环写法:

scores = {"张三"90"李四"58"王五"78"赵六"88}
passed = {}
for name, score in scores.items():
if score >= 80:
        passed[name] = score
print(passed)
5.5 修改字典中的值

给所有学生成绩加 10 分:

scores = {"张三"70"李四"80"王五"90}
new_scores = {name: score + 10for name, score in scores.items()}
print(new_scores)

输出:

{'张三'80'李四'90'王五'100}
5.6 修改字典中的键

把所有姓名前面加上 "学生-"

scores = {"张三"90"李四"85}
result = {f"学生-{name}": score for name, score in scores.items()}
print(result)

输出:

{'学生-张三'90'学生-李四'85}
5.7 键和值互换
scores = {"张三"90"李四"85"王五"78}
result = {score: name for name, score in scores.items()}
print(result)

输出:

{90'张三'85'李四'78'王五'}

注意:如果原字典中的值有重复,互换后会丢失数据。

例如:

scores = {"张三"90"李四"90"王五"78}
result = {score: name for name, score in scores.items()}
print(result)

可能输出:

{90'李四'78'王五'}

因为字典的键不能重复。

当两个学生的成绩都是 90,互换后键都是 90,后面的值会覆盖前面的值。

5.8 使用 enumerate() 创建编号字典
names = ["张三""李四""王五"]
result = {index: name for index, name inenumerate(names, start=1)}
print(result)

输出:

{1'张三'2'李四'3'王五'}
5.9 使用 if...else 处理值

根据成绩生成是否通过:

scores = {"张三"90"李四"58"王五"76}
result = {name: "通过"if score >= 60else"不通过"for name, score in scores.items()}
print(result)

输出:

{'张三''通过''李四''不通过''王五''通过'}
5.10 字典推导式中的键必须可哈希

字典的键必须是不可变、可哈希的数据。

可以作为键的常见类型:

int
float
str
tuple

不能作为键的常见类型:

list
dict
set

错误示例:

data = [[12], [34]]
result = {item: len(item) for item in data}  # 错误

因为 item 是列表,列表不能作为字典的键。

可以改成元组:

data = [[12], [34]]
result = {tuple(item): len(item) for item in data}
print(result)

输出:

{(12): 2, (34): 2}
6. 集合推导式

集合推导式用于快速创建集合。

集合的特点是:

无序、不重复。
6.1 基本语法
{表达式 for 变量 in 可迭代对象}

例如,生成平方集合:

squares = {x * x for x inrange(16)}
print(squares)

输出可能是:

{1491625}

普通循环写法:

squares = set()
for x inrange(16):
    squares.add(x * x)
print(squares)
6.2 自动去重

集合推导式会自动去掉重复元素。

nums = [122333]
result = {x for x in nums}
print(result)

输出:

{123}

这和 set(nums) 的效果类似。

nums = [122333]
result = set(nums)
print(result)

输出:

{123}
6.3 筛选数据并去重

筛选偶数,并自动去重:

nums = [12234456]
evens = {x for x in nums if x % 2 == 0}
print(evens)

输出:

{246}
6.4 提取字符串中的不同字符
text = "banana"
chars = {ch for ch in text}
print(chars)

输出可能是:

{'b''a''n'}

因为集合无序,所以输出顺序不固定。

6.5 统一大小写后去重
words = ["Python""python""JAVA""java"]
result = {word.lower() for word in words}
print(result)

输出:

{'python''java'}
6.6 集合推导式加 if...else

把偶数保留,奇数改成 0,再放入集合:

nums = [12345]
result = {x if x % 2 == 0else0for x in nums}
print(result)

输出:

{024}

注意:多个奇数都会变成 0,集合会自动去重,所以只保留一个 0

6.7 集合推导式和字典推导式的区别

集合推导式:

{x for x inrange(3)}

结果:

{012}

字典推导式:

{x: x * x for x inrange(3)}

结果:

{001124}

区别在于:

集合推导式只有一个表达式。
字典推导式有 key: value。
6.8 空集合不能写成 {}

空集合必须写成:

s = set()

不能写成:

s = {}

因为 {} 表示空字典。

print(type({}))
print(type(set()))

输出:

<class'dict'>
<class'set'>
7. 三种推导式对比

假设有一个列表:

nums = [1234]
7.1 生成列表
result = [x * x for x in nums]
print(result)

输出:

[14916]
7.2 生成字典
result = {x: x * x for x in nums}
print(result)

输出:

{112439416}
7.3 生成集合
result = {x * x for x in nums}
print(result)

输出:

{16149}

输出顺序可能不同,因为集合无序。

7.4 对比表
类型
外层符号
是否有 key:value
是否允许重复
是否有序
列表推导式
[]
允许重复
有序
字典推导式
{}
键不能重复
有序保存插入顺序
集合推导式
{}
不允许重复
无序

注意:

字典在 Python 3.7 及以后会保留插入顺序。
但字典的重点仍然是通过键查找值。
8. 推导式的执行顺序

很多初学者看到推导式会不知道从哪里开始看。

建议从 for 开始读。

例如:

result = [x * 2for x inrange(14)]

阅读顺序:

for x in range(1, 4) 先依次取出 1、2、3
然后执行 x * 2
最后把结果放入列表

所以结果是:

[246]

再看带条件的:

result = [x * 2for x inrange(16if x % 2 == 0]

阅读顺序:

1. 从 range(1, 6) 中取出 x
2. 判断 x % 2 == 0
3. 如果条件成立,就计算 x * 2
4. 把结果放入列表

结果:

[48]
9. 推导式中的 if 位置

推导式中 if 的位置非常重要。

9.1 过滤用的 if 放在后面
result = [x for x inrange(10if x % 2 == 0]

意思是:

只保留偶数。
9.2 if...else 放在前面
result = ["偶数"if x % 2 == 0else"奇数"for x inrange(5)]

意思是:

每个数都处理,只是处理结果不同。
9.3 常见错误

错误写法:

result = [x for x inrange(5if x % 2 == 0else0]

这是错误的。

如果有 else,应该写在 for 前面的表达式中。

正确写法:

result = [x if x % 2 == 0else0for x inrange(5)]
10. 推导式和普通 for 循环的选择

推导式不是必须使用的。

它适合处理简单、清晰的数据转换。

10.1 适合使用推导式的情况

适合:

nums = [1234]
result = [x * 2for x in nums]

适合:

scores = {"张三"90"李四"58}
result = {name: score for name, score in scores.items() if score >= 60}

适合:

words = ["Python""python""Java"]
result = {word.lower() for word in words}

这些代码逻辑都比较短,推导式很清楚。

10.2 不适合使用推导式的情况

如果逻辑很复杂,不推荐强行使用推导式。

例如:

result = [
"优秀"if score >= 90else"良好"if score >= 80else"及格"if score >= 60else"不及格"
for score in scores
]

虽然这段代码可以运行,但可读性不太好。

更推荐写成普通循环:

result = []
for score in scores:
if score >= 90:
        result.append("优秀")
elif score >= 80:
        result.append("良好")
elif score >= 60:
        result.append("及格")
else:
        result.append("不及格")
简单逻辑用推导式。
复杂逻辑用普通 for 循环。
11. 推导式和生成器表达式

圆括号写法不是元组推导式。

result = (x * x for x inrange(5))
print(result)

输出类似:

<generator object <genexpr> at 0x...>

这叫生成器表达式。

生成器不会一次性生成所有数据,而是用到一个生成一个。

11.1 创建元组要使用 tuple()

如果想用类似推导式的方式创建元组,要写:

result = tuple(x * x for x inrange(5))
print(result)

输出:

(014916)

不能认为下面是元组推导式:

result = (x * x for x inrange(5))

它是生成器表达式。

12. 推导式中的变量作用域

在 Python 3 中,推导式内部的变量不会影响外部同名变量。

x = 100
result = [x for x inrange(3)]
print(result)
print(x)

输出:

[012]
100

外面的 x 仍然是 100

例如:

scores = [908578]
result = [score + 5for score in scores]

比下面更清楚:

scores = [908578]
result = [x + 5for x in scores]
13. 推导式中的常见注意事项
13.1 不要为了简短牺牲可读性

推导式不是越短越好。

如果一行写得太复杂,学生和同事都很难读懂。

不推荐:

result = [x * y for x inrange(10for y inrange(10if x % 2 == 0if y % 3 == 0]

如果逻辑复杂,可以写成普通循环。

13.2 不要在推导式中做复杂副作用操作

推导式主要用于生成新数据。

不推荐用它来做打印、写文件、修改外部变量等操作。

不推荐:

[print(x) for x inrange(5)]

更推荐:

for x inrange(5):
print(x)

因为打印的重点是执行动作,不是生成列表。

13.3 字典推导式要注意键重复
data = ["apple""ant""banana""book"]
result = {word[0]: word for word in data}
print(result)

可能输出:

{'a''ant''b''book'}

原因是:

apple 和 ant 的键都是 'a'。
banana 和 book 的键都是 'b'。
后面的值覆盖了前面的值。

字典的键不能重复。

13.4 集合推导式会自动去重
nums = [11223]
result = {x for x in nums}
print(result)

输出:

{123}

如果你需要保留重复元素,就不要用集合推导式。

应该使用列表推导式:

nums = [11223]
result = [x for x in nums]
print(result)

输出:

[11223]
13.5 集合是无序的,不要依赖输出顺序
result = {x for x in [312]}
print(result)

输出顺序不一定是你写入的顺序。

如果需要有顺序的结果,请使用列表推导式。

13.6 空集合不能用 {}
s = {}

这是空字典,不是空集合。

空集合要写:

s = set()
13.7 不要一边遍历字典一边修改原字典

不推荐:

scores = {"张三"90"李四"58}
for name in scores:
if scores[name] < 60:
del scores[name]

这样可能导致运行错误。

如果要筛选字典,推荐创建一个新字典:

scores = {"张三"90"李四"58}
new_scores = {name: score for name, score in scores.items() if score >= 60}
print(new_scores)

输出:

{'张三'90}
13.8 推导式会创建新对象

列表推导式会创建新列表。

nums = [123]
result = [x * 2for x in nums]
print(nums)
print(result)

输出:

[123]
[246]

原列表 nums 没有被修改。

字典推导式和集合推导式也一样,通常是创建新对象。

13.9 数据量特别大时要注意内存

列表推导式会一次性生成完整列表。

result = [x for x inrange(10000000)]

如果数据量非常大,可能占用较多内存。

这种情况下可以考虑生成器表达式:

result = (x for x inrange(10000000))

生成器不会一次性创建所有数据。

初学阶段先掌握列表、字典、集合推导式即可。

14. 综合案例
14.1 批量清洗姓名

需求:

去掉姓名两边空格,并过滤空字符串。

代码:

names = [" 张三 """" 李四""王五 ""   "]
result = [name.strip() for name in names if name.strip()]
print(result)

输出:

['张三''李四''王五']

解释:

name.strip() 去掉空格。
if name.strip() 过滤空字符串。
14.2 给成绩分类
scores = [9582604578]
result = ["优秀"if score >= 90else"合格"if score >= 60else"不合格"for score in scores]
print(result)

输出:

['优秀''合格''合格''不合格''合格']

这段代码可以运行。

不过如果分类更多,建议用普通循环或函数来提高可读性。

14.3 生成学生成绩字典
names = ["张三""李四""王五"]
scores = [908578]
score_dict = {name: score for name, score inzip(names, scores)}
print(score_dict)

输出:

{'张三'90'李四'85'王五'78}
14.4 筛选及格学生
scores = {"张三"90"李四"58"王五"76"赵六"45}
passed = {name: score for name, score in scores.items() if score >= 60}
print(passed)

输出:

{'张三'90'王五'76}
14.5 提取不重复标签
tags = ["Python""python""Java""java""PYTHON"]
result = {tag.lower() for tag in tags}
print(result)

输出:

{'python''java'}
14.6 统计每个单词的长度
words = ["python""java""c"]
result = {word: len(word) for word in words}
print(result)

输出:

{'python'6'java'4'c'1}
14.7 提取二维列表中的偶数
matrix = [
    [123],
    [456],
    [789]
]
evens = [num for row in matrix for num in row if num % 2 == 0]
print(evens)

输出:

[2468]
14.8 统计不同字符
text = "hello python"
chars = {ch for ch in text if ch != " "}
print(chars)
print(len(chars))

输出可能是:

{'e''h''l''o''p''y''t''n'}
8
15. 常见错误汇总
15.1 把字典推导式写成集合推导式

错误理解:

result = {x * x for x inrange(5)}

这不是字典,而是集合。

如果想生成字典,要写成:

result = {x: x * x for x inrange(5)}
15.2 忘记字典推导式中的冒号

错误写法:

result = {x, x * x for x inrange(5)}

正确写法:

result = {x: x * x for x inrange(5)}

字典推导式必须有 key: value

15.3 单纯想打印时使用推导式

不推荐:

[print(x) for x inrange(3)]

推荐:

for x inrange(3):
print(x)
15.4 if...else 位置写错

错误写法:

result = [x for x inrange(5if x % 2 == 0else0]

正确写法:

result = [x if x % 2 == 0else0for x inrange(5)]
15.5 以为集合推导式会保留顺序
result = {x for x in [312]}
print(result)

集合不保证按列表原来的顺序输出。

如果需要顺序,用列表推导式。

15.6 以为圆括号是元组推导式
result = (x for x inrange(5))

这不是元组,而是生成器。

如果要元组:

result = tuple(x for x inrange(5))
15.7 字典键重复导致数据被覆盖
words = ["apple""ant"]
result = {word[0]: word for word in words}
print(result)

输出:

{'a''ant'}

apple 被覆盖了。

如果希望一个键对应多个值,可以使用普通循环配合列表。

words = ["apple""ant""banana""book"]
result = {}
for word in words:
    first = word[0]
if first notin result:
        result[first] = []
    result[first].append(word)
print(result)

输出:

{'a': ['apple''ant'], 'b': ['banana''book']}
16. 练习
练习 1:生成平方列表

请使用列表推导式生成 1 到 10 的平方列表。

参考答案:

result = [x * x for x inrange(111)]
print(result)
练习 2:筛选偶数

有如下列表:

nums = [12345678]

请使用列表推导式筛选出所有偶数。

参考答案:

nums = [12345678]
evens = [x for x in nums if x % 2 == 0]
print(evens)
练习 3:字符串转大写

有如下列表:

words = ["python""java""c++"]

请使用列表推导式把所有字符串转换成大写。

参考答案:

words = ["python""java""c++"]
result = [word.upper() for word in words]
print(result)
练习 4:生成数字平方字典

请使用字典推导式生成 1 到 5 的数字和平方对应关系。

参考答案:

result = {x: x * x for x inrange(16)}
print(result)
练习 5:筛选及格学生

有如下字典:

scores = {"张三"90"李四"58"王五"76}

请使用字典推导式筛选出成绩大于等于 60 的学生。

参考答案:

scores = {"张三"90"李四"58"王五"76}
passed = {name: score for name, score in scores.items() if score >= 60}
print(passed)
练习 6:创建姓名和编号字典

有如下列表:

names = ["张三""李四""王五"]

请生成这样的字典:

{1"张三"2"李四"3"王五"}

参考答案:

names = ["张三""李四""王五"]
result = {index: name for index, name inenumerate(names, start=1)}
print(result)
练习 7:集合去重

有如下列表:

nums = [1223334]

请使用集合推导式去重。

参考答案:

nums = [1223334]
result = {x for x in nums}
print(result)
练习 8:提取不同字符

有如下字符串:

text = "hello"

请使用集合推导式提取其中不同的字符。

参考答案:

text = "hello"
chars = {ch for ch in text}
print(chars)
练习 9:二维列表展平

有如下二维列表:

matrix = [[12], [34], [56]]

请使用列表推导式把它变成:

[123456]

参考答案:

matrix = [[12], [34], [56]]
result = [num for row in matrix for num in row]
print(result)
练习 10:判断成绩是否通过

有如下成绩列表:

scores = [90587645]

请使用列表推导式生成:

["通过""不通过""通过""不通过"]

参考答案:

scores = [90587645]
result = ["通过"if score >= 60else"不通过"for score in scores]
print(result)
17. 总结

推导式是 Python 中非常实用的语法。

可以用一句话总结:

推导式就是用简洁的方式,从旧数据生成新数据。

三种常见推导式:

[表达式 for 变量 in 可迭代对象]                 # 列表推导式
{键表达式: 值表达式 for 变量 in 可迭代对象}     # 字典推导式
{表达式 for 变量 in 可迭代对象}                 # 集合推导式

带条件筛选:

[表达式 for 变量 in 可迭代对象 if 条件]

带 if...else 处理:

[值1if 条件 else 值2for 变量 in 可迭代对象]

记忆口诀:

列表推导用中括号,
字典推导有冒号,
集合推导会去重,
复杂逻辑别硬凑。

最后记住一个原则:

推导式适合简单清晰的转换和筛选。
如果逻辑复杂,普通 for 循环更好读。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-22 00:59:33 HTTP/2.0 GET : https://f.mffb.com.cn/a/505997.html
  2. 运行时间 : 0.115931s [ 吞吐率:8.63req/s ] 内存消耗:4,856.04kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=30b7430ed9373a75358ad4527e60e3ac
  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.000568s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000728s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000258s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000247s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000475s ]
  6. SELECT * FROM `set` [ RunTime:0.000191s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000520s ]
  8. SELECT * FROM `article` WHERE `id` = 505997 LIMIT 1 [ RunTime:0.000763s ]
  9. UPDATE `article` SET `lasttime` = 1787331574 WHERE `id` = 505997 [ RunTime:0.006253s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000221s ]
  11. SELECT * FROM `article` WHERE `id` < 505997 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000436s ]
  12. SELECT * FROM `article` WHERE `id` > 505997 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000411s ]
  13. SELECT * FROM `article` WHERE `id` < 505997 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002733s ]
  14. SELECT * FROM `article` WHERE `id` < 505997 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.009039s ]
  15. SELECT * FROM `article` WHERE `id` < 505997 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.025530s ]
0.118443s