当前位置:首页>python>Python字典操作的15个经典技巧:从入门到让同事惊呼"这也能行?"

Python字典操作的15个经典技巧:从入门到让同事惊呼"这也能行?"

  • 2026-02-05 00:53:10
Python字典操作的15个经典技巧:从入门到让同事惊呼"这也能行?"

为什么字典是Python中最强大的数据结构?

如果Python只能保留一种数据结构,我会毫不犹豫地选择 字典(dict)。

为什么?因为它:

  • 查找速度快: O(1)时间复杂度,比列表快100倍
  • 功能强大: 可以存储任何类型的数据
  • 应用广泛: JSON、配置文件、缓存、数据库查询...处处都是它

但90%的人只会用最基础的增删改查,完全没有发挥出字典的真正威力!

今天,我将分享15个字典的高级技巧,每一个都能让你的代码更优雅、效率提升10倍!

看完这篇文章,你会惊叹:"原来字典还能这么玩!"

技巧1:字典推导式——一行代码创建字典

普通写法(10行代码)

# 创建一个字典:学生姓名 → 成绩students = ['张三''李四''王五''赵六']scores = {}for student in students:    scores[student] = 0print(scores)# {'张三': 0, '李四': 0, '王五': 0, '赵六': 0}

高手写法(1行代码)

scores = {student: 0for student in students}

效率对比: 代码量减少90%,可读性反而更好!

进阶用法:带条件的字典推导式

# 只保留成绩大于60的学生scores = {'张三'85'李四'55'王五'90'赵六'45}passed = {name: score for name, score in scores.items() if score >= 60}print(passed)# {'张三': 85, '王五': 90}# 成绩转换:不及格→0,及格→1status = {name: 1if score >= 60else0for name, score in scores.items()}print(status)# {'张三': 1, '李四': 0, '王五': 1, '赵六': 0}

实战案例:快速统计词频

text = "python is great and python is easy"words = text.split()# 普通写法word_count = {}for word in words:if word in word_count:        word_count[word] += 1else:        word_count[word] = 1# 高手写法(结合collections.Counter更优雅)from collections import Counterword_count = dict(Counter(words))print(word_count)# {'python': 2, 'is': 2, 'great': 1, 'and': 1, 'easy': 1}

技巧2:defaultdict——永远不会KeyError

痛点场景

scores = {}# 这样写会报错!scores['张三'] += 10# KeyError: '张三'# 传统解决方案:每次都要判断if'张三'notin scores:    scores['张三'] = 0scores['张三'] += 10

优雅解决方案:defaultdict

from collections import defaultdict# 自动初始化为0scores = defaultdict(int)scores['张三'] += 10scores['李四'] += 20print(dict(scores))# {'张三': 10, '李四': 20}# 自动初始化为空列表students_by_class = defaultdict(list)students_by_class['一班'].append('张三')students_by_class['一班'].append('李四')students_by_class['二班'].append('王五')print(dict(students_by_class))# {'一班': ['张三', '李四'], '二班': ['王五']}

实战案例:分组统计

# 按部门统计员工employees = [    {'name''张三''dept''技术部'},    {'name''李四''dept''销售部'},    {'name''王五''dept''技术部'},]dept_employees = defaultdict(list)for emp in employees:    dept_employees[emp['dept']].append(emp['name'])print(dict(dept_employees))# {'技术部': ['张三', '王五'], '销售部': ['李四']}

大厂面试常考: 用defaultdict实现图的邻接表存储!

技巧3:Counter——统计神器

Counter的5大妙用

from collections import Counter# 1. 统计列表元素出现次数fruits = ['apple''banana''apple''orange''banana''apple']fruit_count = Counter(fruits)print(fruit_count)# Counter({'apple': 3, 'banana': 2, 'orange': 1})# 2. 找出最常见的元素print(fruit_count.most_common(2))# [('apple', 3), ('banana', 2)]# 3. Counter可以做加减法!counter1 = Counter(['a''b''c'])counter2 = Counter(['b''c''d'])print(counter1 + counter2)  # Counter({'b': 2, 'c': 2, 'a': 1, 'd': 1})print(counter1 - counter2)  # Counter({'a': 1})# 4. 统计字符串字符频率text = "hello world"char_count = Counter(text)print(char_count.most_common(3))# [('l', 3), ('o', 2), ('h', 1)]# 5. 更新计数fruit_count.update(['apple''grape'])print(fruit_count)# Counter({'apple': 4, 'banana': 2, 'orange': 1, 'grape': 1})

实战案例:找出重复文件

from pathlib import Pathfrom collections import Counterdeffind_duplicate_files(folder):"""找出重复的文件名"""    file_names = [f.name for f in Path(folder).iterdir() if f.is_file()]    counts = Counter(file_names)    duplicates = {name: count for name, count in counts.items() if count > 1}return duplicates# 使用duplicates = find_duplicate_files('.')print(f"发现 {len(duplicates)} 个重复文件名")

技巧4:字典合并的3种最优方案

Python 3.9+新特性:合并运算符

dict1 = {'a'1'b'2}dict2 = {'b'3'c'4}# 方法1: | 运算符(Python 3.9+)merged = dict1 | dict2print(merged)  # {'a': 1, 'b': 3, 'c': 4}# 方法2: |= 运算符(就地合并)dict1 |= dict2print(dict1)  # {'a': 1, 'b': 3, 'c': 4}# 方法3: ** 解包(适用于所有版本)merged = {**dict1, **dict2}# 方法4: update()方法dict1.update(dict2)

性能对比

import timeitdict1 = {i: i for i in range(1000)}dict2 = {i: i*2for i in range(10002000)}# 测试不同方法的速度print("| 运算符:", timeit.timeit(lambda: dict1 | dict2, number=10000))print("** 解包:", timeit.timeit(lambda: {**dict1, **dict2}, number=10000))print("update:", timeit.timeit(lambda: dict1.copy().update(dict2), number=10000))

结论| 运算符最快且最简洁!

技巧5:get()方法的高级用法

普通写法

config = {'host''localhost''port'8080}# 可能KeyErrordatabase = config['database']  # KeyError!# 传统解决方案if'database'in config:    database = config['database']else:    database = 'default.db'

优雅写法

# 方法1: get()提供默认值database = config.get('database''default.db')# 方法2: setdefault()获取并设置database = config.setdefault('database''default.db')print(config)  # 现在config中有'database'了!

实战案例:安全读取配置文件

defload_config(config_dict):"""安全加载配置"""return {'host': config_dict.get('host''localhost'),'port': config_dict.get('port'8080),'debug': config_dict.get('debug'False),'timeout': config_dict.get('timeout'30),    }# 即使配置不完整也能正常运行user_config = {'host''192.168.1.1'}final_config = load_config(user_config)print(final_config)# {'host': '192.168.1.1', 'port': 8080, 'debug': False, 'timeout': 30}

技巧6:嵌套字典的优雅处理

痛点场景

data = {'user': {'profile': {'name''张三','age'25        }    }}# 普通写法(容易出错)if'user'in data:if'profile'in data['user']:if'name'in data['user']['profile']:            name = data['user']['profile']['name']

优雅解决方案

# 方法1: 链式get()name = data.get('user', {}).get('profile', {}).get('name''未知')# 方法2: 自定义安全获取函数defsafe_get(data, *keys, default=None):"""安全获取嵌套字典的值"""for key in keys:if isinstance(data, dict):            data = data.get(key, {})else:return defaultreturn data if data != {} else defaultname = safe_get(data, 'user''profile''name', default='未知')age = safe_get(data, 'user''profile''age', default=0)

实战案例:处理API响应

# 模拟API返回的JSON数据api_response = {'status''success','data': {'users': [            {'id'1'name''张三''email''zhangsan@example.com'},            {'id'2'name''李四'}  # 注意:没有email字段        ]    }}# 安全提取所有用户邮箱emails = [    safe_get(user, 'email', default='无邮箱')for user in api_response.get('data', {}).get('users', [])]print(emails)# ['zhangsan@example.com', '无邮箱']

技巧7:字典排序的多种姿势

scores = {'张三'85'李四'92'王五'78'赵六'95}# 1. 按键排序sorted_by_key = dict(sorted(scores.items()))print(sorted_by_key)# 2. 按值排序(升序)sorted_by_value = dict(sorted(scores.items(), key=lambda x: x[1]))print(sorted_by_value)# {'王五': 78, '张三': 85, '李四': 92, '赵六': 95}# 3. 按值排序(降序)sorted_desc = dict(sorted(scores.items(), key=lambda x: x[1], reverse=True))print(sorted_desc)# {'赵六': 95, '李四': 92, '张三': 85, '王五': 78}# 4. 获取Top Nfrom heapq import nlargesttop3 = dict(nlargest(3, scores.items(), key=lambda x: x[1]))print(top3)

技巧8:字典过滤——保留需要的数据

students = {'张三': {'age'20'score'85},'李四': {'age'22'score'55},'王五': {'age'19'score'92},'赵六': {'age'21'score'48}}# 过滤出成绩及格的学生passed = {    name: info for name, info in students.items() if info['score'] >= 60}print(passed)# 过滤出成年学生adults = {    name: info for name, info in students.items() if info['age'] >= 18}

技巧9:字典反转——键值互换

# 简单反转city_code = {'北京''010''上海''021''广州''020'}code_city = {v: k for k, v in city_code.items()}print(code_city)# {'010': '北京', '021': '上海', '020': '广州'}# 处理值重复的情况scores = {'张三'85'李四'92'王五'85}# 反转成:分数 -> 学生列表score_students = defaultdict(list)for student, score in scores.items():    score_students[score].append(student)print(dict(score_students))# {85: ['张三', '王五'], 92: ['李四']}

技巧10:ChainMap——优雅处理多层配置

from collections import ChainMap# 场景:应用配置的优先级user_config = {'theme''dark''font_size'14}default_config = {'theme''light''font_size'12'language''zh'}# 合并配置(user_config优先)config = ChainMap(user_config, default_config)print(config['theme'])      # 'dark' (来自user_config)print(config['language'])   # 'zh' (来自default_config)print(dict(config))# {'theme': 'dark', 'font_size': 14, 'language': 'zh'}

技巧11:字典性能优化技巧

1. 使用字典查找而不是if-elif链

# 慢!defget_weekday(num):if num == 1:return'星期一'elif num == 2:return'星期二'elif num == 3:return'星期三'# ...# 快!WEEKDAYS = {1'星期一'2'星期二'3'星期三'4'星期四',5'星期五'6'星期六'7'星期日'}defget_weekday(num):return WEEKDAYS.get(num, '无效日期')

2. 缓存计算结果

from functools import lru_cache# 不使用缓存:每次都重新计算deffibonacci(n):if n < 2:return nreturn fibonacci(n-1) + fibonacci(n-2)# 使用缓存:计算过的直接返回@lru_cache(maxsize=None)deffibonacci_cached(n):if n < 2:return nreturn fibonacci_cached(n-1) + fibonacci_cached(n-2)# 性能差异巨大!import timestart = time.time()print(fibonacci(35))print(f"无缓存: {time.time() - start:.2f}秒")  # ~3秒start = time.time()print(fibonacci_cached(35))print(f"有缓存: {time.time() - start:.2f}秒")  # ~0.0001秒

技巧12:字典解包的妙用

# 函数参数解包defcreate_user(name, age, city):returnf"{name}{age}岁, 来自{city}"user_info = {'name''张三''age'25'city''北京'}result = create_user(**user_info)# 合并多个字典dict1 = {'a'1'b'2}dict2 = {'c'3'd'4}dict3 = {'e'5}merged = {**dict1, **dict2, **dict3}

技巧13:字典与JSON的完美配合

import json# Python字典 → JSON字符串data = {'name''张三''age'25'skills': ['Python''SQL']}json_str = json.dumps(data, ensure_ascii=False, indent=2)print(json_str)# JSON字符串 → Python字典json_data = '{"name": "李四", "age": 30}'python_dict = json.loads(json_data)# 保存到文件with open('data.json''w', encoding='utf-8'as f:    json.dump(data, f, ensure_ascii=False, indent=2)# 从文件读取with open('data.json''r', encoding='utf-8'as f:    loaded_data = json.load(f)

技巧14:字典的深拷贝与浅拷贝

import copyoriginal = {'a'1'b': [234]}# 浅拷贝:只复制第一层shallow = original.copy()shallow['b'].append(5)print(original)  # {'a': 1, 'b': [2, 3, 4, 5]}  ← 原字典也变了!# 深拷贝:完全独立deep = copy.deepcopy(original)deep['b'].append(6)print(original)  # {'a': 1, 'b': [2, 3, 4, 5]}  ← 原字典不变print(deep)      # {'a': 1, 'b': [2, 3, 4, 5, 6]}

技巧15:字典的高级模式——工厂模式

# 策略模式:用字典管理不同的处理函数defprocess_json(data):return json.loads(data)defprocess_csv(data):return data.split(',')defprocess_xml(data):returnf"XML: {data}"# 处理器字典PROCESSORS = {'json': process_json,'csv': process_csv,'xml': process_xml}defprocess_data(data, format_type):"""根据格式类型选择处理器"""    processor = PROCESSORS.get(format_type)if processor:return processor(data)else:raise ValueError(f"不支持的格式: {format_type}")# 使用result = process_data('{"name": "张三"}''json')print(result)

实战综合案例:学生成绩管理系统

让我们把上面学到的技巧综合运用:

from collections import defaultdict, Counterimport jsonclassStudentManager:def__init__(self):        self.students = {}defadd_student(self, student_id, name, **scores):"""添加学生(使用**kwargs接收任意科目成绩)"""        self.students[student_id] = {'name': name,'scores': scores        }defget_average(self, student_id):"""计算学生平均分"""        scores = self.students.get(student_id, {}).get('scores', {})ifnot scores:return0return sum(scores.values()) / len(scores)defget_top_students(self, n=3):"""获取成绩最好的N个学生"""        averages = {            sid: self.get_average(sid) for sid in self.students        }        top = sorted(averages.items(), key=lambda x: x[1], reverse=True)[:n]return [            {'id': sid,'name': self.students[sid]['name'],'average': avg            }for sid, avg in top        ]defget_subject_stats(self):"""统计各科目平均分"""        subject_scores = defaultdict(list)for student in self.students.values():for subject, score in student['scores'].items():                subject_scores[subject].append(score)return {            subject: sum(scores) / len(scores)for subject, scores in subject_scores.items()        }defexport_to_json(self, filename):"""导出数据"""with open(filename, 'w', encoding='utf-8'as f:            json.dump(self.students, f, ensure_ascii=False, indent=2)defimport_from_json(self, filename):"""导入数据"""with open(filename, 'r', encoding='utf-8'as f:            self.students = json.load(f)# 使用示例manager = StudentManager()manager.add_student('001''张三', 语文=85, 数学=92, 英语=88)manager.add_student('002''李四', 语文=78, 数学=95, 英语=82)manager.add_student('003''王五', 语文=92, 数学=88, 英语=90)print("Top 3学生:")print(manager.get_top_students(3))print("\n各科平均分:")print(manager.get_subject_stats())manager.export_to_json('students.json')

总结:字典使用的黄金法则

✅ 应该做的:

  1. 优先使用字典而不是if-elif链
  2. 使用get()方法而不是直接索引
  3. 用defaultdict避免KeyError
  4. 用Counter进行统计
  5. 用字典推导式简化代码
  6. 记得深拷贝嵌套字典

❌ 不应该做的:

  1. ❌ 不要用字符串拼接键名:dict[f"{prefix}_{key}"]
  2. ❌ 不要在循环中反复查找:for i in range(n): value = dict[key]
  3. ❌ 不要用字典存储大量数值计算(用NumPy)
  4. ❌ 不要用可变对象(列表、字典)作为键

性能对比总结表

操作
列表
字典
性能提升
查找元素
O(n)
O(1)
n倍
插入元素
O(1)
O(1)
相当
删除元素
O(n)
O(1)
n倍
检查存在
O(n)
O(1)
n倍

结论: 需要频繁查找、检查时,字典完胜列表!

下一步学习建议

掌握了这15个技巧,你已经是字典高手了!接下来可以:

  1. 实践: 用字典重构你的旧代码
  2. 深入: 学习OrderedDict、WeakValueDictionary等高级类型
  3. 扩展: 了解Redis等键值数据库的原理

记住:工具不在多,在于精。把字典用到极致,你就是Python高手!

如果这篇文章对你有帮助,请点赞、收藏、转发!你的支持是我创作的最大动力! 🚀

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-07 17:06:16 HTTP/2.0 GET : https://f.mffb.com.cn/a/471332.html
  2. 运行时间 : 0.203093s [ 吞吐率:4.92req/s ] 内存消耗:4,419.56kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=aec4a720f5c63d0a121233480bf377e4
  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.000887s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000736s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.005512s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.009377s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000521s ]
  6. SELECT * FROM `set` [ RunTime:0.001366s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000609s ]
  8. SELECT * FROM `article` WHERE `id` = 471332 LIMIT 1 [ RunTime:0.023456s ]
  9. UPDATE `article` SET `lasttime` = 1770455176 WHERE `id` = 471332 [ RunTime:0.053785s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000311s ]
  11. SELECT * FROM `article` WHERE `id` < 471332 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.004378s ]
  12. SELECT * FROM `article` WHERE `id` > 471332 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.009555s ]
  13. SELECT * FROM `article` WHERE `id` < 471332 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002831s ]
  14. SELECT * FROM `article` WHERE `id` < 471332 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.011773s ]
  15. SELECT * FROM `article` WHERE `id` < 471332 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.006876s ]
0.204699s