当前位置:首页>python>第3.6章:快速学习Python的JSON 与配置文件

第3.6章:快速学习Python的JSON 与配置文件

  • 2026-08-18 23:12:05
第3.6章:快速学习Python的JSON 与配置文件

《Python AI 应用开发入门》第 3.6 节。

读写并验证 JSON 配置与聊天历史,实现配置和代码分离。

本节目标

学完本节后,你应当能够:

  1. 1. 区分 JSON 文本与 Python 对象。
  2. 2. 使用 dumps()loads()dump() 和 load()
  3. 3. 使用 UTF-8 保存可读中文 JSON。
  4. 4. 读取并验证应用配置。
  5. 5. 读写结构化聊天历史。
  6. 6. 处理文件不存在、JSON 损坏和字段错误。
  7. 7. 使用临时文件降低写入中断风险。
  8. 8. 避免在配置文件中保存真实 API Key。

1. JSON 是什么

JSON 是跨语言交换结构化数据的文本格式:

{  "model": "demo-model",  "temperature": 0.7,  "streaming":false,  "system_prompt":null}

它看起来像 Python 字典,但不是 Python 代码。

JSON
Python
object
dict
array
list
string
str
number
int
 或 float
true
 / false
True
 / False
nullNone

JSON 不支持元组、集合、Path 和任意 Python 对象。写入前必须转换为 JSON 可表示的数据。

2. dumps():对象变字符串

import jsonconfig = {    "model": "demo-model",    "temperature": 0.7,    "streaming": False,}text = json.dumps(    config,    ensure_ascii=False,    indent=2,)print(text)
  • • ensure_ascii=False:中文直接显示,不转成 \u...
  • • indent=2:格式化为便于阅读的多行文本。

结果是 str,还没有写入文件。

3. loads():字符串变对象

import jsontext = '{"model": "demo-model", "temperature": 0.7}'config = json.loads(text)print(type(config))print(config["model"])

JSON 无效时触发 json.JSONDecodeError

# json.loads('{"model": "demo-model",}')

标准 JSON 不允许最后一个字段后保留多余逗号,也不允许普通注释。

4. dump() 与 load()

它们直接操作已经打开的文件对象:

import jsonfrom pathlib import Pathpath = Path("config.json")config = {"model": "demo-model", "max_history": 50}with path.open(mode="w", encoding="utf-8") as file:    json.dump(config, file, ensure_ascii=False, indent=2)

读取:

with path.open(mode="r", encoding="utf-8") as file:    loaded_config = json.load(file)

对比:

  • • dumps / loads 中的 s 可以记作 string。
  • • dump / load 处理文件对象。

本课程也常用 Path.read_text() 配合 loads(),因为异常边界更容易看清。

5. JSON 解析成功不等于配置有效

下面是合法 JSON:

{  "model": "",  "max_history": -10}

但业务配置无效。因此读取配置分两步:

  1. 1. 解析 JSON 语法。
  2. 2. 验证数据结构、类型和范围。

不能只要 json.loads() 成功就直接使用。

6. 配置文件设计

chat_app/data/config.json

{  "model": "demo-model",  "style": "简洁",  "max_history": 50}

配置适合保存:

  • • 模型名称。
  • • 非敏感功能开关。
  • • 数量限制。
  • • 文件位置。
  • • 显示风格。

不适合保存并提交:

  • • 真实 API Key。
  • • 密码。
  • • 访问令牌。
  • • 私密连接字符串。

敏感配置应从环境变量或专门密钥服务读取。

7. 读取并验证配置

JSON 数据来自文件,类型注解不能自动验证它是否符合要求,因此需要在程序运行时检查。isinstance() 是 Python 内置的类型检查函数,基本语法是:

isinstance(对象, 类型)

对象属于指定类型时返回 True,否则返回 False

print(isinstance("demo-model", str))  # Trueprint(isinstance(50, int))            # Trueprint(isinstance([], dict))           # False

第二个参数也可以传入由多个类型组成的元组:

print(isinstance(3.5, (int, float)))  # True

not isinstance(data, dict) 可以读作“data 不是字典”。相比 type(data) == dict,通常更推荐 isinstance(),因为它也能识别指定类型的子类。

下面使用它检查 JSON 根节点和各个配置项的类型:

import jsonfrom pathlib import Pathfrom typing import AnyDEFAULT_CONFIG = {    "model": "demo-model",    "style": "简洁",    "max_history": 50,}def load_config(path: Path) -> dict[str, Any]:    if not path.exists():        return DEFAULT_CONFIG.copy()    try:        text = path.read_text(encoding="utf-8")        data = json.loads(text)    except PermissionError as error:        raise ValueError(f"没有权限读取配置:{path}") from error    except UnicodeDecodeError as error:        raise ValueError(f"配置文件不是有效 UTF-8:{path}") from error    except json.JSONDecodeError as error:        raise ValueError(            f"配置 JSON 无效,第 {error.lineno} 行第 {error.colno} 列"        ) from error    if not isinstance(data, dict):        raise ValueError("配置根节点必须是 JSON object")    model = data.get("model")    style = data.get("style", DEFAULT_CONFIG["style"])    max_history = data.get(        "max_history",        DEFAULT_CONFIG["max_history"],    )    if not isinstance(model, str) or not model.strip():        raise ValueError("model 必须是非空字符串")    if not isinstance(style, str) or not style.strip():        raise ValueError("style 必须是非空字符串")    if (        not isinstance(max_history, int)        or isinstance(max_history, bool)        or max_history <= 0    ):        raise ValueError("max_history 必须是大于 0 的整数")    return {        "model": model.strip(),        "style": style.strip(),        "max_history": max_history,    }

注意:bool 是 int 的子类,所以整数校验时额外排除布尔值。

8. 聊天历史 JSON

[  {    "role": "user",    "content": "什么是 JSON?"  },  {    "role": "assistant",    "content": "JSON 是结构化文本格式。"  }]

它自然对应:

list[dict[str, str]]

9. 验证单条消息

from typing import Anydef validate_message(value: Any) -> dict[str, str]:    if not isinstance(value, dict):        raise ValueError("每条消息必须是 JSON object")    role = value.get("role")    content = value.get("content")    if role not in ("system", "user", "assistant"):        raise ValueError("消息 role 无效")    if not isinstance(content, str) or not content.strip():        raise ValueError("消息 content 必须是非空字符串")    return {        "role": role,        "content": content,    }

解析外部数据后不能依赖类型注解,必须运行时检查。

10. 加载聊天历史

import jsonfrom pathlib import Pathdef load_history(path: Path) -> list[dict[str, str]]:    if not path.exists():        return []    try:        data = json.loads(path.read_text(encoding="utf-8"))    except json.JSONDecodeError as error:        raise ValueError(            f"聊天历史 JSON 无效,第 {error.lineno} 行"        ) from error    if not isinstance(data, list):        raise ValueError("聊天历史根节点必须是 JSON array")    messages = []    for index, value in enumerate(data, start=1):        try:            message = validate_message(value)        except ValueError as error:            raise ValueError(f"第 {index} 条消息无效:{error}") from error        messages.append(message)    return messages

错误信息包含消息序号,定位更容易。

11. 保存聊天历史

import jsonfrom pathlib import Pathdef save_history(    path: Path,    messages: list[dict[str, str]],) -> None:    validated_messages = []    for message in messages:        validated_messages.append(validate_message(message))    path.parent.mkdir(parents=True, exist_ok=True)    text = json.dumps(        validated_messages,        ensure_ascii=False,        indent=2,    )    path.write_text(text + "\n", encoding="utf-8")

写入前再次验证,避免把无效内存数据持久化。

12. 使用临时文件再替换

直接覆盖时如果程序中途终止,原文件可能只写了一部分。可以先写临时文件:

def save_history(    path: Path,    messages: list[dict[str, str]],) -> None:    validated_messages = []    for message in messages:        validated_message = validate_message(message)        validated_messages.append(validated_message)    text = json.dumps(        validated_messages,        ensure_ascii=False,        indent=2,    )    path.parent.mkdir(parents=True, exist_ok=True)    temporary_path = path.with_suffix(path.suffix + ".tmp")    temporary_path.write_text(text + "\n", encoding="utf-8")    temporary_path.replace(path)

替换通常比直接逐步覆盖更安全,但它不是数据库事务,也没有解决多个进程同时写入的问题。

13. 限制历史长度

def trim_history(    messages: list[dict[str, str]],    max_history: int,) -> list[dict[str, str]]:    if max_history <= 0:        raise ValueError("max_history 必须大于 0")    return messages[-max_history:]

保存前:

messages = trim_history(messages, config["max_history"])save_history(history_path, messages)

返回新列表,不暗中修改调用者传入的原列表。

14. 入口层处理配置错误

def main() -> None:    try:        config = load_config(CONFIG_PATH)        messages = load_history(HISTORY_PATH)    except ValueError as error:        print(f"启动失败:{error}")        return    print(f"模型:{config['model']}")    print(f"恢复消息:{len(messages)} 条")

配置损坏时不要静默使用默认值,否则用户可能不知道自己的设置完全没有生效。文件不存在可以明确设计为首次启动并使用默认值。

15. JSON 常见问题

把 Python 字面量写进 JSON

错误:

{  "streaming": True,  "system_prompt": None}

JSON 必须使用 true 和 null

保存集合

# json.dumps({"tags": {"Python", "AI"}})

集合不可直接序列化,应先转换为排序后的列表:

data = {"tags": sorted({"Python", "AI"})}

把 JSON 当安全配置

JSON 只是文本格式,不会自动加密或隐藏内容。

动手练习

练习 1:配置加载器

完成 load_config(path),测试:

  • • 文件不存在。
  • • JSON 语法错误。
  • • 根节点不是 object。
  • • 缺少必填 model
  • • max_history 为布尔值、负数和有效整数。

练习 2:历史持久化

实现 load_history() 与 save_history()。保存三条中文消息,关闭程序后重新加载并比较内容。

练习 3:损坏数据定位

手工把第二条消息的 content 改成空字符串,确认错误信息能指出“第 2 条消息”。

随堂小测

  1. 1. JSON 与 Python 字典是什么关系?
  2. 2. dumps() 与 dump() 有什么区别?
  3. 3. ensure_ascii=False 有什么作用?
  4. 4. 为什么解析成功后仍要验证配置?
  5. 5. JSONDecodeError 提供哪些定位信息?
  6. 6. 为什么整数校验要排除 bool
  7. 7. 临时文件替换降低了什么风险?
  8. 8. 真实 API Key 为什么不能写入 JSON 并提交?
  9. 9. 文件不存在和文件损坏是否应该使用相同策略?

参考答案

  1. 1. JSON object 解析后通常得到 Python 字典,但 JSON 是独立文本格式,不是 Python 代码。
  2. 2. dumps() 返回字符串,dump() 写入已打开的文件对象。
  3. 3. 让中文按原字符显示。
  4. 4. 合法 JSON 仍可能有错误结构、类型、缺失字段或越界值。
  5. 5. 错误消息、行号和列号等。
  6. 6. Python 中 bool 是 int 的子类,但业务上通常不能把真假当数量。
  7. 7. 减少原文件被截断后只写入部分内容的风险。
  8. 8. JSON 是明文,仓库、日志和其他人都可能读取。
  9. 9. 不一定。不存在可以代表首次启动;损坏通常应明确报错,避免静默忽略用户数据。

本节完成检查

  • • 我能在 JSON 与 Python 对象之间转换。
  • • 我使用 UTF-8 保存了可读中文 JSON。
  • • 我把解析和业务验证分成两步。
  • • 我能报告 JSON 的具体行列错误。
  • • 我验证了配置和每条聊天消息。
  • • 我使用临时文件方式保存历史。
  • • 我没有把真实密钥写入配置。
  • • 我完成了三个动手练习。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-21 15:37:12 HTTP/2.0 GET : https://f.mffb.com.cn/a/510300.html
  2. 运行时间 : 0.254224s [ 吞吐率:3.93req/s ] 内存消耗:4,792.70kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=153e9cbb54c0790c4335a6418d184046
  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.000873s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001301s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.010283s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.003723s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001365s ]
  6. SELECT * FROM `set` [ RunTime:0.016661s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001442s ]
  8. SELECT * FROM `article` WHERE `id` = 510300 LIMIT 1 [ RunTime:0.001021s ]
  9. UPDATE `article` SET `lasttime` = 1787297832 WHERE `id` = 510300 [ RunTime:0.010914s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000601s ]
  11. SELECT * FROM `article` WHERE `id` < 510300 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001167s ]
  12. SELECT * FROM `article` WHERE `id` > 510300 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001098s ]
  13. SELECT * FROM `article` WHERE `id` < 510300 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.005827s ]
  14. SELECT * FROM `article` WHERE `id` < 510300 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.015523s ]
  15. SELECT * FROM `article` WHERE `id` < 510300 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.018900s ]
0.257835s