当前位置:首页>python>Python字典详解

Python字典详解

  • 2026-06-30 15:05:01
Python字典详解

字典(Dictionary)是Python中最重要的数据结构之一,用于存储键值对(key-value pairs)。Python字典提供了高效的键值查找机制,是日常开发中最常用的数据结构之一。本文将详细介绍Python字典的特性、操作和最佳实践。

一、字典概述

1. 什么是字典?

字典是Python中的一种无序、可变的映射类型(Mapping Type),用于存储键值对集合。每个键值对之间用逗号,分隔,整个字典用花括号{}包裹。

2. 字典的特点

  • 无序性
    :Python 3.7之前字典是无序的,Python 3.7及以后版本字典保持插入顺序
  • 可变性
    :字典创建后可以修改其内容(添加、删除、修改键值对)
  • 映射关系
    :通过键(key)映射到对应的值(value)
  • 键的唯一性
    :字典中的键必须唯一
  • 键的可哈希性
    :字典的键必须是可哈希的(不可变类型,如字符串、数字、元组)
  • 值的任意性
    :字典的值可以是任意类型(包括可变类型,如列表、字典)

3. 字典的表示

字典使用花括号{}表示,键值对之间用冒号:分隔:

# 字典示例person ={"name":"张三","age":30,"city":"北京"}# 键可以是不同类型mixed ={1:"整数键","字符串键":2,(1,2):"元组键"}# 空字典empty_dict ={}

二、字典的创建

1. 基本创建方法

使用花括号{}直接创建字典:

# 基本创建方法示例# 创建空字典empty ={}# 创建包含键值对的字典person ={"name":"李四","age":25,"email":"lisi@example.com"}# 使用不同类型的键mixed ={1:"数字键","字符串键":"字符串值",(1,2):"元组键",True:"布尔键"}print(empty)# {}print(person)# {'name': '李四', 'age': 25, 'email': 'lisi@example.com'}print(mixed)# {1: '布尔键', '字符串键': '字符串值', (1, 2): '元组键'}(注意True和1在字典中视为同一个键)

2. 使用dict()函数创建

dict()函数可以从不同的数据源创建字典:

# 使用dict()函数创建字典示例# 从关键字参数创建=dict(name="王五", age=35, city="上海")print(d)# {'name': '王五', 'age': 35, 'city': '上海'}# 从键值对序列创建pairs =[("name","赵六"),("age",40),("city","广州")]=dict(pairs)print(d)# {'name': '赵六', 'age': 40, 'city': '广州'}# 从两个列表创建(使用zip()函数)keys =["name","age","city"]values =["钱七",45,"深圳"]=dict(zip(keys, values))print(d)# {'name': '钱七', 'age': 45, 'city': '深圳'}# 从另一个字典创建(浅拷贝)original ={"name":"孙八","age":50}=dict(original)print(d)# {'name': '孙八', 'age': 50}print(is original)# False(创建了新字典)

3. 使用字典推导式创建

字典推导式是一种简洁创建字典的方法,语法为{key_expression: value_expression for item in iterable if condition}

# 使用字典推导式创建字典示例# 基本字典推导式numbers =[1,2,3,4,5]squares ={num: num **2for num in numbers}print(squares)# {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}# 带有条件的字典推导式even_squares ={num: num **2for num in numbers if num %2==0}print(even_squares)# {2: 4, 4: 16}# 使用两个列表创建=["name","age","city"]=["周九",55,"杭州"]person ={k: v for k, v inzip(a, b)}print(person)# {'name': '周九', 'age': 55, 'city': '杭州'}# 转换字符串为字符计数字典word ="hello"char_count ={char: word.count(char)for char in word}print(char_count)# {'h': 1, 'e': 1, 'l': 2, 'o': 1}

4. 使用fromkeys()方法创建

fromkeys()方法可以从序列创建字典,所有键的初始值相同:

# 使用fromkeys()方法创建字典示例# 创建所有键值为None的字典keys =["name","age","city"]=dict.fromkeys(keys)print(d)# {'name': None, 'age': None, 'city': None}# 创建所有键值为相同值的字典=dict.fromkeys(keys,"默认值")print(d)# {'name': '默认值', 'age': '默认值', 'city': '默认值'}# 注意:如果默认值是可变对象,所有键会共享同一个对象keys =["a","b","c"]=dict.fromkeys(keys,[])d["a"].append(1)print(d)# {'a': [1], 'b': [1], 'c': [1]}(所有键共享同一个列表)

三、字典的基本操作

1. 访问字典元素

可以通过键来访问字典中的值:

# 访问字典元素示例person ={"name":"吴十","age":60,"city":"南京"}# 使用方括号访问print(person["name"])# 吴十print(person["age"])# 60# 访问不存在的键会报错try:print(person["email"])except KeyError as e:print(f"错误:{e}")# 错误:'email'# 使用get()方法访问(更安全)print(person.get("name"))# 吴十print(person.get("email"))# None(键不存在时返回None)print(person.get("email","默认邮箱"))# 默认邮箱(键不存在时返回指定的默认值)

2. 修改字典元素

可以通过键来修改字典中的值:

# 修改字典元素示例person ={"name":"郑十一","age":65,"city":"成都"}# 修改现有键的值person["age"]=70print(person)# {'name': '郑十一', 'age': 70, 'city': '成都'}# 使用update()方法修改多个键值对person.update({"age":75,"city":"重庆"})print(person)# {'name': '郑十一', 'age': 75, 'city': '重庆'}# 使用关键字参数修改person.update(age=80, city="西安")print(person)# {'name': '郑十一', 'age': 80, 'city': '西安'}

3. 添加字典元素

可以通过赋值或update()方法添加新的键值对:

# 添加字典元素示例person ={"name":"王十二","age":30}# 添加新的键值对person["city"]="武汉"print(person)# {'name': '王十二', 'age': 30, 'city': '武汉'}# 使用update()方法添加多个键值对person.update({"email":"wang12@example.com","phone":"13800138000"})print(person)# {'name': '王十二', 'age': 30, 'city': '武汉', 'email': 'wang12@example.com', 'phone': '13800138000'}# 使用关键字参数添加person.update(gender="男")print(person)# {'name': '王十二', 'age': 30, 'city': '武汉', 'email': 'wang12@example.com', 'phone': '13800138000', 'gender': '男'}

4. 删除字典元素

可以使用多种方法删除字典中的元素:

# 删除字典元素示例person ={"name":"赵十三","age":35,"city":"长沙","email":"zhao13@example.com"}# 使用del语句删除print(person)# {'name': '赵十三', 'age': 35, 'city': '长沙', 'email': 'zhao13@example.com'}del person["city"]print(person)# {'name': '赵十三', 'age': 35, 'email': 'zhao13@example.com'}# 删除不存在的键会报错try:del person["phone"]except KeyError as e:print(f"错误:{e}")# 错误:'phone'# 使用pop()方法删除(返回被删除的值)email = person.pop("email")print(email)# zhao13@example.comprint(person)# {'name': '赵十三', 'age': 35}# pop()方法可以指定默认值(键不存在时返回默认值)phone = person.pop("phone","默认电话")print(phone)# 默认电话print(person)# {'name': '赵十三', 'age': 35}# 使用popitem()方法删除最后一个键值对(Python 3.7+)pair = person.popitem()print(pair)# ('age', 35)print(person)# {'name': '赵十三'}# 使用clear()方法清空字典person.clear()print(person)# {}

5. 字典的其他基本操作

# 字典的其他基本操作示例person ={"name":"钱十四","age":40,"city":"青岛"}# 获取字典的长度(键值对数量)print(len(person))# 3# 检查键是否存在print("name"in person)# Trueprint("email"notin person)# True# 字典的复制(浅拷贝)person2 = person.copy()print(person2)# {'name': '钱十四', 'age': 40, 'city': '青岛'}print(person2 is person)# False# 字典的合并person3 ={"email":"qian14@example.com","phone":"13900139000"}merged ={**person,**person3}print(merged)# {'name': '钱十四', 'age': 40, 'city': '青岛', 'email': 'qian14@example.com', 'phone': '13900139000'}# Python 3.9+支持使用|运算符合并# merged = person | person3

四、字典的常用方法

Python字典提供了丰富的方法用于操作字典:

1. keys()、values()和items()

这些方法用于获取字典的键、值和键值对:

# keys()、values()和items()方法示例person ={"name":"孙十五","age":45,"city":"济南"}# 获取所有键keys = person.keys()print(keys)# dict_keys(['name', 'age', 'city'])print(list(keys))# ['name', 'age', 'city']# 获取所有值values = person.values()print(values)# dict_values(['孙十五', 45, '济南'])print(list(values))# ['孙十五', 45, '济南']# 获取所有键值对items = person.items()print(items)# dict_items([('name', '孙十五'), ('age', 45), ('city', '济南')])print(list(items))# [('name', '孙十五'), ('age', 45), ('city', '济南')]# 遍历字典的键for key in person.keys():print(key)# 遍历字典的值for value in person.values():print(value)# 遍历字典的键值对for key, value in person.items():print(f"{key}{value}")

2. get()方法

get()方法用于获取指定键的值,如果键不存在则返回默认值:

# get()方法示例person ={"name":"周十六","age":50,"city":"福州"}# 获取存在的键print(person.get("name"))# 周十六# 获取不存在的键(返回None)print(person.get("email"))# None# 获取不存在的键(返回默认值)print(person.get("email","no email"))# no email# 获取不存在的键(返回默认值)print(person.get("phone",1234567890))# 1234567890

3. update()方法

update()方法用于更新字典中的键值对:

# update()方法示例person ={"name":"吴十七","age":55,"city":"厦门"}# 使用字典更新person.update({"age":60,"email":"wu17@example.com"})print(person)# {'name': '吴十七', 'age': 60, 'city': '厦门', 'email': 'wu17@example.com'}# 使用关键字参数更新person.update(age=65, phone="13800138000")print(person)# {'name': '吴十七', 'age': 65, 'city': '厦门', 'email': 'wu17@example.com', 'phone': '13800138000'}# 使用键值对序列更新person.update([("city","南宁"),("gender","男")])print(person)# {'name': '吴十七', 'age': 65, 'city': '南宁', 'email': 'wu17@example.com', 'phone': '13800138000', 'gender': '男'}

4. setdefault()方法

setdefault()方法用于获取指定键的值,如果键不存在则添加该键并设置默认值:

# setdefault()方法示例person ={"name":"郑十八","age":70,"city":"昆明"}# 获取存在的键name = person.setdefault("name","默认姓名")print(name)# 郑十八print(person)# {'name': '郑十八', 'age': 70, 'city': '昆明'}# 获取不存在的键(添加键并设置默认值)email = person.setdefault("email","默认邮箱")print(email)# 默认邮箱print(person)# {'name': '郑十八', 'age': 70, 'city': '昆明', 'email': '默认邮箱'}# 获取不存在的键(默认值为None)phone = person.setdefault("phone")print(phone)# Noneprint(person)# {'name': '郑十八', 'age': 70, 'city': '昆明', 'email': '默认邮箱', 'phone': None}

5. 其他方法

# 其他方法示例# 创建字典d1 ={"a":1,"b":2,"c":3}d2 ={"c":4,"d":5,"e":6}# 使用copy()方法复制字典d3 = d1.copy()print(d3)# {'a': 1, 'b': 2, 'c': 3}# 使用clear()方法清空字典d3.clear()print(d3)# {}# 使用pop()方法删除键值对value = d1.pop("a")print(value)# 1print(d1)# {'b': 2, 'c': 3}# 使用popitem()方法删除最后一个键值对pair = d1.popitem()print(pair)# ('c', 3)print(d1)# {'b': 2}

五、字典的高级操作

1. 嵌套字典

字典中可以包含其他字典,形成嵌套字典:

# 嵌套字典示例# 创建嵌套字典student ={"name":"王十九","age":18,"scores":{"数学":95,"语文":90,"英语":85},"address":{"city":"贵阳","street":"解放路","zipcode":"550000"}}# 访问嵌套字典中的元素print(student["name"])# 王十九print(student["scores"]["数学"])# 95print(student["address"]["city"])# 贵阳# 修改嵌套字典中的元素student["scores"]["数学"]=100print(student["scores"]["数学"])# 100# 添加嵌套字典中的元素student["scores"]["物理"]=92print(student["scores"])# {'数学': 100, '语文': 90, '英语': 85, '物理': 92}# 遍历嵌套字典for subject, score in student["scores"].items():print(f"{subject}{score}")# 遍历整个嵌套字典for key, value in student.items():ifisinstance(value,dict):print(f"{key}:")for k, v in value.items():print(f"  {k}{v}")else:print(f"{key}{value}")

2. 字典推导式

字典推导式是一种简洁创建字典的方法:

# 字典推导式示例# 基本字典推导式numbers =[1,2,3,4,5]squares ={num: num **2for num in numbers}print(squares)# {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}# 带有条件的字典推导式even_squares ={num: num **2for num in numbers if num %2==0}print(even_squares)# {2: 4, 4: 16}# 使用两个列表创建keys =["name","age","city"]values =["赵二十",20,"拉萨"]person ={k: v for k, v inzip(keys, values)}print(person)# {'name': '赵二十', 'age': 20, 'city': '拉萨'}# 转换字符串为字符计数字典word ="python"char_count ={char: word.count(char)for char in word}print(char_count)# {'p': 1, 'y': 1, 't': 1, 'h': 1, 'o': 1, 'n': 1}# 反转字典键值对original ={"a":1,"b":2,"c":3}reversed_dict ={v: k for k, v in original.items()}print(reversed_dict)# {1: 'a', 2: 'b', 3: 'c'}# 注意:如果原字典的值不唯一,反转后会丢失一些键值对original ={"a":1,"b":2,"c":1}reversed_dict ={v: k for k, v in original.items()}print(reversed_dict)# {1: 'c', 2: 'b'}('a'键丢失)

3. 字典的排序

可以使用sorted()函数对字典进行排序:

# 字典的排序示例# 创建字典scores ={"数学":95,"语文":90,"英语":85,"物理":92,"化学":88}# 按键排序for key insorted(scores.keys()):print(f"{key}{scores[key]}")# 按键排序并创建新字典keys_sorted ={k: scores[k]for k insorted(scores.keys())}print(keys_sorted)# {'化学': 88, '物理': 92, '数学': 95, '英语': 85, '语文': 90}# 按值排序for key, value insorted(scores.items(), key=lambda x: x[1]):print(f"{key}{value}")# 按值降序排序for key, value insorted(scores.items(), key=lambda x: x[1], reverse=True):print(f"{key}{value}")# 按值的绝对值排序scores ={"a":-5,"b":3,"c":-1,"d":2}for key, value insorted(scores.items(), key=lambda x:abs(x[1])):print(f"{key}{value}")

4. 字典的合并

Python提供了多种合并字典的方法:

# 字典的合并示例dict1 ={"a":1,"b":2}dict2 ={"b":3,"c":4}# 方法1:使用update()方法(会修改原字典)dict1_copy = dict1.copy()dict1_copy.update(dict2)print(dict1_copy)# {'a': 1, 'b': 3, 'c': 4}# 方法2:使用**运算符(Python 3.5+)merged ={**dict1,**dict2}print(merged)# {'a': 1, 'b': 3, 'c': 4}# 方法3:使用字典推导式merged ={k: v for d in[dict1, dict2]for k, v in d.items()}print(merged)# {'a': 1, 'b': 3, 'c': 4}# 方法4:使用chain()函数(from itertools)from itertools import chainmerged =dict(chain(dict1.items(), dict2.items()))print(merged)# {'a': 1, 'b': 3, 'c': 4}# 方法5:使用|运算符(Python 3.9+)# merged = dict1 | dict2# print(merged)  # {'a': 1, 'b': 3, 'c': 4}

5. 字典的键值对转换

可以将字典转换为其他数据结构:

# 字典的键值对转换示例person ={"name":"钱二十一","age":21,"city":"银川"}# 转换为列表keys_list =list(person.keys())values_list =list(person.values())items_list =list(person.items())print(keys_list)# ['name', 'age', 'city']print(values_list)# ['钱二十一', 21, '银川']print(items_list)# [('name', '钱二十一'), ('age', 21), ('city', '银川')]# 转换为元组keys_tuple =tuple(person.keys())values_tuple =tuple(person.values())items_tuple =tuple(person.items())print(keys_tuple)# ('name', 'age', 'city')print(values_tuple)# ('钱二十一', 21, '银川')print(items_tuple)# (('name', '钱二十一'), ('age', 21), ('city', '银川'))# 转换为集合keys_set =set(person.keys())values_set =set(person.values())print(keys_set)# {'name', 'age', 'city'}print(values_set)# {'钱二十一', 21, '银川'}

六、字典的性能分析

1. 时间复杂度

字典的核心优势是高效的键值查找,主要操作的时间复杂度如下:

操作
时间复杂度
描述
访问元素
O(1)
通过键访问值
修改元素
O(1)
通过键修改值
添加元素
O(1)
添加新的键值对
删除元素
O(1)
删除键值对
成员检查
O(1)
检查键是否存在
获取所有键
O(n)
获取字典的所有键
获取所有值
O(n)
获取字典的所有值
获取所有键值对
O(n)
获取字典的所有键值对

2. 性能优化建议

  • 尽量使用不可变类型作为键(字符串、数字、元组)
  • 避免使用可变类型作为键(列表、字典)
  • 使用get()方法而不是[]访问元素(避免KeyError)
  • 对于频繁查找的场景,字典比列表更高效
  • 对于需要保持插入顺序的场景,使用Python 3.7+的字典

3. 字典与列表的性能比较

# 字典与列表的性能比较示例import time# 创建大列表和大字典=1000000my_list =list(range(n))my_dict ={i: i for i inrange(n)}# 测试列表的查找性能start = time.time()for i inrange(n):if i == n -1:passend = time.time()print(f"列表查找耗时:{end - start:.6f}秒")# 测试字典的查找性能start = time.time()for i inrange(n):if i in my_dict:passend = time.time()print(f"字典查找耗时:{end - start:.6f}秒")

七、字典的最佳实践

1. 适用场景

  • 需要通过键快速查找值的场景
  • 需要存储键值对集合的场景
  • 需要表示对象属性的场景
  • 需要缓存数据的场景
  • 需要存储配置信息的场景

2. 最佳实践

# 最佳实践示例# 1. 使用有意义的键名# 不好的做法user ={"n":"张三","a":30,"c":"北京"}# 好的做法user ={"name":"张三","age":30,"city":"北京"}# 2. 使用get()方法访问元素(避免KeyError)# 不好的做法try:    email = user["email"]except KeyError:    email =""# 好的做法email = user.get("email","")# 3. 使用字典推导式创建字典# 不好的做法numbers =[1,2,3,4,5]squares ={}for num in numbers:    squares[num]= num **2# 好的做法squares ={num: num **2for num in numbers}# 4. 避免使用可变类型作为键# 不好的做法try:    bad_dict ={[1,2]:"值"}except TypeError as e:print(f"错误:{e}")# 错误:unhashable type: 'list'# 好的做法good_dict ={(1,2):"值"}# 使用元组作为键# 5. 合理使用嵌套字典# 好的做法student ={"name":"李四","age":20,"scores":{"数学":95,"语文":90,"英语":85}}# 6. 使用zip()函数创建字典# 好的做法keys =["name","age","city"]values =["王五",25,"上海"]person =dict(zip(keys, values))

3. 常见错误

# 常见错误示例# 错误1:使用可变类型作为键try:    d ={[1,2]:"值"}except TypeError as e:print(f"错误:{e}")# 错误:unhashable type: 'list'# 错误2:访问不存在的键try:    d ={"a":1,"b":2}print(d["c"])except KeyError as e:print(f"错误:{e}")# 错误:'c'# 错误3:修改不可哈希的键try:    d ={(1,2):"值"}    d[(1,2)][0]=3except TypeError as e:print(f"错误:{e}")# 错误:'tuple' object does not support item assignment# 错误4:混淆字典的键和值={"a":1,"b":2}# 不好的做法for value in d:print(value)# 输出键,不是值# 好的做法for key in d:print(d[key])# 输出值for value in d.values():print(value)# 输出值

八、与其他数据结构的比较

特性
字典
列表
元组
存储方式
键值对
元素序列
元素序列
访问方式
通过键
通过索引
通过索引
可变性
可变
可变
不可变
有序性
Python 3.7+有序
有序
有序
键的唯一性
键必须唯一
元素可以重复
元素可以重复
可哈希性
键必须可哈希
不可哈希
可哈希
查找效率
O(1)
O(n)
O(n)
内存占用
较大
较小
较小
适用场景
键值映射、快速查找
有序元素集合、需要频繁修改
不可变元素集合、需要作为字典键

九、总结

字典是Python中最强大、最灵活的数据结构之一,具有以下特点:

  1. 高效的键值查找
    :字典的核心优势是O(1)时间复杂度的键值查找
  2. 灵活的键值对存储
    :可以存储任意类型的键值对
  3. 可变性
    :可以动态添加、修改、删除键值对
  4. 丰富的操作方法
    :提供了大量用于操作字典的方法
  5. 广泛的应用场景
    :在日常开发中几乎无处不在

通过掌握Python字典的特性和操作方法,可以编写出更高效、更优雅的代码。在实际开发中,应根据具体需求选择合适的数据结构,充分发挥字典的优势。


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

作者:张荣殿

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 12:18:26 HTTP/2.0 GET : https://f.mffb.com.cn/a/497192.html
  2. 运行时间 : 0.529542s [ 吞吐率:1.89req/s ] 内存消耗:5,591.53kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=f85e3161ab9129cd447346fdb7c6ef13
  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.000796s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001712s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.004300s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.001393s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001435s ]
  6. SELECT * FROM `set` [ RunTime:0.019195s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001640s ]
  8. SELECT * FROM `article` WHERE `id` = 497192 LIMIT 1 [ RunTime:0.041584s ]
  9. UPDATE `article` SET `lasttime` = 1783052306 WHERE `id` = 497192 [ RunTime:0.001451s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.005462s ]
  11. SELECT * FROM `article` WHERE `id` < 497192 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.032893s ]
  12. SELECT * FROM `article` WHERE `id` > 497192 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.067670s ]
  13. SELECT * FROM `article` WHERE `id` < 497192 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.100150s ]
  14. SELECT * FROM `article` WHERE `id` < 497192 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.127420s ]
  15. SELECT * FROM `article` WHERE `id` < 497192 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.033607s ]
0.533217s