当前位置:首页>python>Python教程 - 自动化运维与脚本实战

Python教程 - 自动化运维与脚本实战

  • 2026-08-18 23:10:41
Python教程 - 自动化运维与脚本实战

欢迎来到 Python 自动化运维专题!学到这里你已经掌握了变量、循环、函数、类、爬虫、数据分析、异步编程等核心技能。现在我们要换个口味——让 Python 成为你的"万能瑞士军刀",帮你搞定电脑上那些繁琐、重复的日常任务。

这一期不讲究什么高大上的架构,我们就聚焦一个问题:**怎么用 Python 写脚本自动干实事?**

---

## 一、文件系统操作:让文件自己管自己

### 1.1 遍历目录与批量重命名

假设你在下载了一个月的电影资源,名字乱七八糟,你想把它们统一规范一下。用 `os` 和 `pathlib` 就能轻松搞定。

```python

from pathlib import Path

import shutil

from datetime import datetime

defbatch_rename_movie(folderstr) -> None:

"""把文件夹里所有 mp4 文件重命名为 '电影001.mp4' 这种格式"""

    dir_path = Path(folder)

    files = sorted(dir_path.glob("*.mp4"))  # 拿到所有 mp4 文件并排序

for idx, file inenumerate(files, start=1):

        new_name = f"电影{idx:03d}{file.suffix}"

        new_path = file.with_name(new_name)

if file != new_path:

            file.rename(new_path)

print(f"{file.name} → {new_name}")

# 使用示例:

# batch_rename_movie(r"D:\\Downloads\\movies")

```

### 1.2 智能分类整理下载文件夹

更实用的是,根据文件类型自动归类到一个文件夹里的各个子文件夹中。

```python

from pathlib import Path

FOLDER_MAP = {

".jpg""图片"".jpeg""图片"".png""图片"".gif""图片"".webp""图片",

".mp4""视频"".avi""视频"".mkv""视频"".mov""视频",

".pdf""文档"".docx""文档"".txt""文档"".xlsx""文档",

".mp3""音乐"".flac""音乐"".wav""音乐",

".zip""压缩包"".rar""压缩包"".7z""压缩包"".tar.gz""压缩包",

".exe""安装包"".dmg""安装包",

}

defsmart_sort(download_dirstr) -> None:

"""把下载目录里的文件分类到对应子文件夹"""

    root = Path(download_dir)

for file in root.iterdir():

ifnot file.is_file():

continue

        ext = file.suffix.lower()

        category = FOLDER_MAP.get(ext, "其他")

        dest = root / category / file.name

        dest.parent.mkdir(exist_ok=True)

ifnot dest.exists():

            shutil.move(str(file), str(dest))

print(f"[{category}{file.name}")

else:

print(f"[跳过] {file.name} 已存在")

# 使用示例:

# smart_sort(r"D:\\Downloads")

```

运行一次,你的下载文件夹立刻变清爽。

### 1.3 练习

1. 写一个函数,找出某个文件夹下超过 1GB 的大文件,并列出它们的完整路径和大小(以 MB 为单位)。

2. 编写脚本,将指定目录下所有 `.py` 文件的注释行(以 `#` 开头的行)统计出来,输出每份文件的注释行数。

3. 实现一个"重复文件查找器"——扫描一个目录树,打印出 MD5 相同的文件组。提示:使用 `hashlib.md5()` 计算文件摘要。

---

## 二、命令行工具:让终端成为你的第二工作台

### 2.1 用 argparse 编写专业命令行的脚本

Python 内置的 `argparse` 模块让你可以写出像 `ls``git` 那样有 `-h` 帮助的命令行程序。

```python

import argparse

import os

from pathlib import Path

defmain():

    parser = argparse.ArgumentParser(

prog="fsearch",

description="在指定目录及其子目录中搜索文件名匹配模式的文件",

    )

    parser.add_argument("pattern"help="搜索模式(支持 * 通配符)")

    parser.add_argument("-d""--directory"default="."help="搜索根目录(默认当前目录)")

    parser.add_argument("-e""--extension"default=Nonehelp="仅匹配扩展名,如 .py / .txt")

    parser.add_argument("--size-gt"type=intdefault=None,

help="只显示大于指定字节数的文件")

    parser.add_argument("--count-only"action="store_true",

help="只输出结果数量,不显示详细信息")

    args = parser.parse_args()

    root = Path(args.directory)

ifnot root.is_dir():

print(f"错误:{args.directory} 不是一个有效的目录"flush=True)

return

    matches = []

for file in root.rglob(args.pattern):

ifnot file.is_file():

continue

if args.extension and file.suffix != args.extension:

continue

if args.size_gt and file.stat().st_size <= args.size_gt:

continue

        matches.append(file)

if args.count_only:

print(f"共找到 {len(matches)} 个匹配文件"flush=True)

else:

for m in matches:

            size_mb = m.stat().st_size / (1024 * 1024)

print(f"{m} ({size_mb:.2f} MB)")

print(f"\n总计 {len(matches)} 个文件"flush=True)

if__name__ == "__main__":

    main()

```

你可以这样使用:

```bash

# 搜索所有 txt 文件

pythonfsearch"*.txt"-dD:/Documents

# 只看超过 1MB 的 Python 文件

pythonfsearch"*.py"-dC:/Projects--size-gt1048576

# 只返回数量

pythonfsearch"*report*"--count-only

```

### 2.2 subprocess:在 Python 里调用系统命令

有时候光靠 Python 标准库不够用,我们需要调用系统自带的工具(比如 `ping``du``top`)。

```python

import subprocess

# ===== 用法 1:简单执行 =====

result = subprocess.run(["echo""Hello from Python"],

capture_output=Truetext=True)

print("输出:", result.stdout.strip())

# ===== 用法 2:调用 ping 检查网络 =====

defcheck_host(hoststrtimeoutint = 5) -> bool:

"""检查目标主机是否在线"""

    param = "-n"if os.name == "nt"else"-c"

    cmd = ["ping", param, "1""-W"str(timeout), host]

try:

        proc = subprocess.run(cmd, capture_output=Truetext=Truetimeout=timeout+2)

return proc.returncode == 0

except subprocess.TimeoutExpired:

returnFalse

# print(check_host("127.0.0.1"))  # True

# ===== 用法 3:读取 df/du 命令的输出做磁盘分析 =====

import os

defdisk_usage_summary(top_dirstr = "/") -> dict:

"""获取磁盘使用概要"""

    result = subprocess.run(["du""-sh", top_dir],

capture_output=Truetext=True)

    lines = result.stdout.strip().split("\n")

    info = {}

for line in lines:

        parts = line.split()

iflen(parts) >= 2:

            info[parts[1]] = parts[0]

return info

# print(disk_usage_summary("."))

```

### 2.3 练习

4. 用 `subprocess` 写一个脚本,监控指定进程(如 `chrome.exe`)的 CPU 和内存占用,每隔 5 秒输出一行报告。

5. 编写一个"定时清理脚本"——每天凌晨 2 点用 `at` 或 `schtasks`(Windows)执行一次,删除临时目录中超过 30 天的文件。

---

## 三、计划任务与邮件通知

### 3.1 用 sched 模块实现轻量级定时任务

不需要装 Celery 或者 cron,标准库就有 `sched` 可以用。

```python

import sched

import time

import os

from pathlib import Path

scheduler = sched.scheduler(time.time, time.sleep)

defclean_temp_files(sc: sched.scheduler):

"""删除 temp 目录下超过 7 天的文件"""

    temp_dir = Path.home() / "AppData" / "Local" / "Temp"

    cutoff = time.time() - 7 * 86400# 7 天前

    cleaned = 0

if temp_dir.exists():

for f in temp_dir.glob("*"):

if f.is_file() and f.stat().st_mtime < cutoff:

                f.unlink()

                cleaned += 1

print(f"[{time.strftime('%Y-%m-%d %H:%M')}] 已清理 {cleaned} 个过期临时文件")

# 继续安排下一次执行(每天 3 点)

    sc.enter(864001, clean_temp_files, (sc,))

# 启动任务

scheduler.enter(01, clean_temp_files, (scheduler,))

try:

    scheduler.run()

exceptKeyboardInterrupt:

print("\n任务已停止")

```

### 3.2 发送通知邮件

脚本跑完了,怎么告诉你结果?发邮件最方便。

```python

import smtplib

from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart

defsend_email(

smtp_serverstr,

smtp_portint,

senderstr,

passwordstr,

recipientstr,

subjectstr,

bodystr,

htmlbool = False,

) -> bool:

"""通过 SMTP 发送邮件(支持 SSL)"""

    msg = MIMEMultipart()

    msg["From"] = sender

    msg["To"] = recipient

    msg["Subject"] = subject

    content_type = "html"if html else"plain"

    msg.attach(MIMEText(body, content_type, "utf-8"))

try:

with smtplib.SMTP_SSL(smtp_server, smtp_port) as server:

            server.login(sender, password)

            server.sendmail(sender, recipient, msg.as_string())

print(f"✅ 邮件已发送至 {recipient}")

returnTrue

exceptExceptionas e:

print(f"❌ 邮件发送失败: {e}")

returnFalse

# 使用示例(以 QQ 邮箱为例):

# send_email(

#     smtp_server="smtp.qq.com",

#     smtp_port=465,

#     sender="your@qq.com",

#     password="your_smtp_authorization_code",  # QQ邮箱需要在设置里获取"授权码"

#     recipient="admin@company.com",

#     subject="服务器监控报告",

#     body="CPU 正常,内存 72%,磁盘 45%",

# )

```

### 3.3 练习

6. 将上面的 `clean_temp_files` 和 `send_email` 组合起来:每天清理完临时文件后,自动给你发一封邮件报告清理了多少文件、剩余多少空间。

7. 编写一个"服务器健康检查"脚本:每隔 10 分钟用 `ping` 检查三个站点(127.0.0.1、8.8.8.8、114.114.114.114),如果任何目标不可达就发邮件告警。

---

## 四、注册表与系统信息:Windows 特供

### 4.1 读取系统配置

在 Windows 上我们可以直接读写注册表。下面用一个简单的例子来读取系统信息。

```python

import winreg

import platform

import socket

defget_windows_info() -> dict:

"""收集基础 Windows 系统信息"""

    info = {

"hostname": socket.gethostname(),

"platform": platform.platform(),

"python_version": platform.python_version(),

"cpu_count": platform.cpu_count(),

"username": os.environ.get("USERNAME""unknown"),

    }

# 从注册表读取安装日期

try:

        key = winreg.OpenKey(

            winreg.HKEY_LOCAL_MACHINE,

r"SOFTWARE\Microsoft\Windows NT\CurrentVersion",

        )

        install_date, _ = winreg.QueryValueEx(key, "InstallDate")

        info["install_date_timestamp"] = int(install_date)

        winreg.CloseKey(key)

exceptFileNotFoundError:

        info["install_date"] = "无法读取"

exceptExceptionas e:

        info["install_date_error"] = str(e)

return info

for k, v in get_windows_info().items():

print(f"  {k}{v}")

```

>**说明**`winreg` 只在 Windows 平台可用。如果你在 macOS/Linux 上,可以改用 `psutil` 库来获取跨平台的系统信息。

### 4.2 用 psutil 做系统监控(第三方库)

```bash

pipinstallpsutil

```

```python

import psutil

import time

defsystem_monitor(intervalint = 5roundsint = 3) -> None:

"""周期性输出系统资源使用情况"""

print(f"{'时间':>19}{'CPU%':>7}{'内存%':>7}{'磁盘%':>7}")

print("-" * 48)

for _ inrange(rounds):

        ts = time.strftime("%Y-%m-%d %H:%M:%S")

        cpu = psutil.cpu_percent(interval=None)

        mem = psutil.virtual_memory().percent

        disk = psutil.disk_usage("/").percent

print(f"{ts:>19}{cpu:>6.1f}%  {mem:>6.1f}%  {disk:>6.1f}%")

        time.sleep(interval)

# system_monitor(interval=5, rounds=5)

```

运行效果大致如下:

```

                    时间        CPU%      内存%      磁盘%

------------------------------------------------

2026-07-14 09:50:10     12.5%     64.3%     45.2%

2026-07-14 09:50:15     15.8%     64.5%     45.2%

2026-07-14 09:50:20     8.3%      64.4%     45.2%

2026-07-14 09:50:25     22.1%     64.6%     45.2%

2026-07-14 09:50:30     6.7%      64.5%     45.2%

```

---

## 五、综合实战:一键搭建"个人运维仪表盘"

现在我们把前面学的所有东西串在一起,写一个完整的脚本,它可以:

1. 扫描指定目录下的所有文件,统计容量分布

2. 检查系统资源使用情况

3. 把结果保存到一个汇总报告文件里

4. (可选)通过邮件发送给你自己

```python

#!/usr/bin/env python3

"""

daily_health.py — 每日系统健康检查脚本

用法:python daily_health.py [--email recipient@example.com]

"""

import argparse

import json

import os

import platform

import shutil

import subprocess

import time

from datetime import datetime

from pathlib import Path

try:

import psutil

HAS_PSUTIL = True

exceptImportError:

HAS_PSUTIL = False

defscan_directories(dirs: list[str]) -> dict:

"""扫描指定目录的大小分布"""

    results = {}

for d in dirs:

        p = Path(d)

ifnot p.exists():

            results[d] = {"error""目录不存在"}

continue

        total = 0

        by_ext: dict[strint] = {}

        file_count = 0

for f in p.rglob("*"):

if f.is_file():

                size = f.stat().st_size

                total += size

                file_count += 1

                ext = f.suffix.lower() or"(无扩展名)"

                by_ext[ext] = by_ext.get(ext, 0) + size

        results[d] = {

"total_bytes": total,

"file_count": file_count,

"by_extension"dict(sorted(by_ext.items(), key=lambdax: -x[1]))[:10],

        }

return results

defget_system_info() -> dict:

"""获取系统资源状态"""

    info = {"host": platform.node(), "platform": platform.platform()}

ifHAS_PSUTIL:

        info.update({

"cpu_percent": psutil.cpu_percent(interval=1),

"memory_total_gb"round(psutil.virtual_memory().total / (1024 ** 3), 1),

"memory_used_percent": psutil.virtual_memory().percent,

"disk_usage_percent": psutil.disk_usage("/").percent,

        })

else:

# 回退方案:调用系统命令

try:

            out = subprocess.check_output(

                ["systeminfo"" | findstr /C:\"总物理内存\""],

text=Trueshell=True,

            )

            info["systeminfo_stdout"] = out.strip()

exceptException:

            info["psutil_not_available"] = "请安装 pip install psutil"

return info

defbuild_report(scan_dirs: list[str], emailstr | None = None) -> str:

"""组装并输出报告"""

    now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

    scan_data = scan_directories(scan_dirs)

    sys_data = get_system_info()

    report_lines = [

f"===== 每日系统健康报告 {now} =====",

"",

"--- 系统状态 ---",

        json.dumps(sys_data, ensure_ascii=Falseindent=2),

"",

"--- 目录扫描 ---",

    ]

for d, data in scan_data.items():

        mb = data.get("total_bytes"0) / (1024 * 1024)

        report_lines.append(f"  {d}{mb:.1f} MB, {data.get('file_count''?')} 个文件")

for ext, size in data.get("by_extension", {}).items():

            kb = size / 1024

if kb > 1024:

                report_lines.append(f"    .{ext.lstrip('.')}{kb/1024:.1f} MB")

else:

                report_lines.append(f"    .{ext.lstrip('.')}{kb:.0f} KB")

    report_text = "\n".join(report_lines) + "\n"

# 保存到文件

    out_dir = Path.home() / "AppData" / "Local" / "health_reports"

    out_dir.mkdir(parents=Trueexist_ok=True)

    report_file = out_dir / f"health_{datetime.now().strftime('%Y%m%d_%H%M%S')}.txt"

    report_file.write_text(report_text, encoding="utf-8")

print(f"📄 报告已保存到: {report_file}")

# 如果有 psutil 且数据异常,可以触发邮件告警逻辑

# send_email(...)  # 参见前面 send_email 函数定义

return report_text

if__name__ == "__main__":

    parser = argparse.ArgumentParser(description="每日系统健康检查")

    parser.add_argument(

"dirs"nargs="+"help="要扫描的目录列表",

    )

    parser.add_argument("--email"help="接收报告的邮箱地址(可选)")

    args = parser.parse_args()

    report = build_report(args.dirs, args.email)

print("\n" + report)

```

运行:

```bash

pythondaily_health.pyD:\DownloadsD:\DocumentsD:\Projects

pythondaily_health.pyD:--emailyour@email.com

```

---

## 六、总结与进阶路线

这一期我们学会了:

| 模块 | 用途 | 一句话概括 |

|------|------|-----------|

`pathlib` / `os` | 文件系统管理 | 像文件管理器一样操控文件夹 |

`argparse` | 命令行接口 | 让你的脚本像专业工具一样好用 |

`subprocess` | 调用外部命令 | Python 的"外挂"工具箱 |

`sched` | 轻量调度器 | 不需要 cron 的定时方案 |

`smtplib` | 邮件通知 | 脚本执行完,结果到手了 |

`psutil` | 系统监控 | 实时看 CPU、内存、磁盘 |

`winreg` | Windows 注册表 | 读取系统安装信息等配置 |

### 下一步怎么走?

自动化运维是通向"工程师思维"的桥梁——不再只是写代码,而是让代码替你工作。接下来的进阶方向:

-**Ansible / SaltStack**:大规模服务器批量运维

-**Django Admin 自定义**:把脚本封装成 Web 管理面板

-**CI/CD 流水线**:用 GitHub Actions 或 Jenkins 自动化测试和部署

---

## 七、练习题参考

以下是前面练习题的参考答案思路:

**练习 1**(查找大文件):

```python

from pathlib import Path

deffind_large_files(folderstrthreshold_mbfloat = 100) -> list[tuple[strfloat]]:

    results = []

for f in Path(folder).rglob("*"):

if f.is_file() and f.stat().st_size > threshold_mb * 1024 * 1024:

            results.append((str(f), f.stat().st_size / (1024 * 1024)))

returnsorted(results, key=lambdax: -x[1])

```

**练习 2**(统计注释行数):

```python

from pathlib import Path

defcount_comments(folderstr) -> dict[strint]:

    results = {}

for f in Path(folder).rglob("*.py"):

        comments = sum(1for line in f.read_text(encoding="utf-8"errors="ignore")

if line.strip().startswith("#"))

        results[str(f)] = comments

return results

```

**练习 3**(重复文件检测):

```python

import hashlib

from pathlib import Path

deffind_duplicates(folderstr) -> dict[str, list[str]]:

defmd5sum(filepathstr) -> str:

        h = hashlib.md5()

withopen(filepath, "rb"as f:

            h.update(f.read())

return h.hexdigest()

    hash_map: dict[str, list[str]] = {}

for f in Path(folder).rglob("*"):

if f.is_file():

            h = md5sum(str(f))

            hash_map.setdefault(h, []).append(str(f))

# 只保留有多份的文件组

return {k: v for k, v in hash_map.items() iflen(v) > 1}

```

---

**下期预告(Episode 16)****Python 与云服务交互**—— 用 `requests` / `boto3` 对接云 API,自动化上传下载 S3/OSS 文件、管理云函数触发器、调用阿里云/腾讯云 OCR 和语音接口,打造真正的"云端自动化"。敬请期待!

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-08-21 17:59:34 HTTP/2.0 GET : https://f.mffb.com.cn/a/505416.html
  2. 运行时间 : 0.526020s [ 吞吐率:1.90req/s ] 内存消耗:4,660.80kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=c7c786123ef3e28c2ea44f589e6e9df7
  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.001207s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.002219s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000875s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000806s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001592s ]
  6. SELECT * FROM `set` [ RunTime:0.000577s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001533s ]
  8. SELECT * FROM `article` WHERE `id` = 505416 LIMIT 1 [ RunTime:0.012415s ]
  9. UPDATE `article` SET `lasttime` = 1787306374 WHERE `id` = 505416 [ RunTime:0.042302s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000836s ]
  11. SELECT * FROM `article` WHERE `id` < 505416 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001973s ]
  12. SELECT * FROM `article` WHERE `id` > 505416 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001291s ]
  13. SELECT * FROM `article` WHERE `id` < 505416 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.077307s ]
  14. SELECT * FROM `article` WHERE `id` < 505416 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.129646s ]
  15. SELECT * FROM `article` WHERE `id` < 505416 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.079695s ]
0.529830s