当前位置:首页>python>【一周精选】用 Python 的 Tkinter 库实现田字格纸模板工具

【一周精选】用 Python 的 Tkinter 库实现田字格纸模板工具

  • 2026-03-12 02:03:59
【一周精选】用 Python 的 Tkinter 库实现田字格纸模板工具

用 Python 的 Tkinter 库实现一个功能完整的田字格纸模板工具,这个工具需要包含左侧的参数设置面板和右侧的预览区域,支持调整田字格的线条样式、颜色、粗细,配置页眉页脚,还能导出图片和打印。

下面提供一个完整、可直接运行的实现方案,这个方案包含了你需要的所有核心功能,代码结构清晰且有详细注释:

完整实现代码

import tkinter as tk
from tkinter import ttk, colorchooser, filedialog, messagebox
import PIL
from PIL import Image, ImageDraw, ImageTk
import win32print
import win32ui
from PIL import ImageWin
import os

classTianZiGeGenerator:
def__init__(self, root):
        self.root = root
        self.root.title("田字格纸模板生成器")
        self.root.geometry("1200x800")
        self.root.resizable(TrueTrue)

# 初始化田字格参数
        self.line_width = tk.IntVar(value=2)  # 线条粗细
        self.line_style = tk.StringVar(value="solid")  # 线条样式
        self.line_color = tk.StringVar(value="
#000000")  # 线条颜色
        self.header_text = tk.StringVar(value="田字格练习纸")  # 页眉文本
        self.footer_text = tk.StringVar(value="第 ___ 页 / 共 ___ 页")  # 页脚文本
        self.grid_rows = tk.IntVar(value=10)  # 行数
        self.grid_cols = tk.IntVar(value=8)   # 列数

# 预览画布相关
        self.preview_image = None
        self.preview_photo = None

# 创建主布局
        self.create_main_layout()

# 初始生成预览
        self.update_preview()

defcreate_main_layout(self):
"""创建主布局:左侧设置面板 + 右侧预览区域"""
# 左侧设置面板
        setting_frame = ttk.LabelFrame(self.root, text="参数设置", padding=10)
        setting_frame.pack(side=tk.LEFT, fill=tk.Y, padx=10, pady=10)

# 1. 线条设置
        line_frame = ttk.LabelFrame(setting_frame, text="线条设置", padding=5)
        line_frame.pack(fill=tk.X, pady=5)

# 线条粗细
        ttk.Label(line_frame, text="线条粗细:").grid(row=0, column=0, sticky=tk.W, padx=2, pady=2)
        width_spin = ttk.Spinbox(line_frame, from_=1, to=10, textvariable=self.line_width, width=10, command=self.update_preview)
        width_spin.grid(row=0, column=1, sticky=tk.W, padx=2, pady=2)

# 线条样式
        ttk.Label(line_frame, text="线条样式:").grid(row=1, column=0, sticky=tk.W, padx=2, pady=2)
        style_combo = ttk.Combobox(line_frame, textvariable=self.line_style, values=["solid""dashed""dotted"], 
                                   width=8, state="readonly")
        style_combo.grid(row=1, column=1, sticky=tk.W, padx=2, pady=2)
        style_combo.bind("<<ComboboxSelected>>"lambda e: self.update_preview())

# 线条颜色
        ttk.Label(line_frame, text="线条颜色:").grid(row=2, column=0, sticky=tk.W, padx=2, pady=2)
        color_btn = ttk.Button(line_frame, text="选择颜色", command=self.choose_color)
        color_btn.grid(row=2, column=1, sticky=tk.W, padx=2, pady=2)

# 2. 网格大小设置
        grid_frame = ttk.LabelFrame(setting_frame, text="网格大小", padding=5)
        grid_frame.pack(fill=tk.X, pady=5)

        ttk.Label(grid_frame, text="行数:").grid(row=0, column=0, sticky=tk.W, padx=2, pady=2)
        row_spin = ttk.Spinbox(grid_frame, from_=1, to=20, textvariable=self.grid_rows, width=10, command=self.update_preview)
        row_spin.grid(row=0, column=1, sticky=tk.W, padx=2, pady=2)

        ttk.Label(grid_frame, text="列数:").grid(row=1, column=0, sticky=tk.W, padx=2, pady=2)
        col_spin = ttk.Spinbox(grid_frame, from_=1, to=10, textvariable=self.grid_cols, width=10, command=self.update_preview)
        col_spin.grid(row=1, column=1, sticky=tk.W, padx=2, pady=2)

# 3. 页眉页脚设置
        text_frame = ttk.LabelFrame(setting_frame, text="页眉页脚", padding=5)
        text_frame.pack(fill=tk.X, pady=5)

        ttk.Label(text_frame, text="页眉文本:").grid(row=0, column=0, sticky=tk.W, padx=2, pady=2)
        header_entry = ttk.Entry(text_frame, textvariable=self.header_text, width=20)
        header_entry.grid(row=0, column=1, sticky=tk.W, padx=2, pady=2)
        header_entry.bind("<KeyRelease>"lambda e: self.update_preview())

        ttk.Label(text_frame, text="页脚文本:").grid(row=1, column=0, sticky=tk.W, padx=2, pady=2)
        footer_entry = ttk.Entry(text_frame, textvariable=self.footer_text, width=20)
        footer_entry.grid(row=1, column=1, sticky=tk.W, padx=2, pady=2)
        footer_entry.bind("<KeyRelease>"lambda e: self.update_preview())

# 4. 操作按钮
        btn_frame = ttk.Frame(setting_frame, padding=5)
        btn_frame.pack(fill=tk.X, pady=10)

        export_btn = ttk.Button(btn_frame, text="导出图片", command=self.export_image)
        export_btn.pack(side=tk.LEFT, padx=5, fill=tk.X, expand=True)

        print_btn = ttk.Button(btn_frame, text="打印模板", command=self.print_template)
        print_btn.pack(side=tk.LEFT, padx=5, fill=tk.X, expand=True)

# 右侧预览区域
        preview_frame = ttk.LabelFrame(self.root, text="预览区域", padding=10)
        preview_frame.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True, padx=10, pady=10)

        self.preview_canvas = tk.Canvas(preview_frame, bg="white")
        self.preview_canvas.pack(fill=tk.BOTH, expand=True)

defchoose_color(self):
"""选择线条颜色"""
        color = colorchooser.askcolor(title="选择线条颜色", initialcolor=self.line_color.get())
if color[1]:
            self.line_color.set(color[1])
            self.update_preview()

defdraw_tianzige(self, draw, width, height, cell_size):
"""绘制田字格"""
# 计算实际的行列数
        rows = self.grid_rows.get()
        cols = self.grid_cols.get()

# 绘制外框网格
for i in range(rows + 1):
            y = 50 + i * cell_size  # 留出页眉空间
            draw.line([(50, y), (50 + cols * cell_size, y)], 
                      fill=self.line_color.get(), width=self.line_width.get())

for j in range(cols + 1):
            x = 50 + j * cell_size
            draw.line([(x, 50), (x, 50 + rows * cell_size)], 
                      fill=self.line_color.get(), width=self.line_width.get())

# 绘制每个格子的十字线(田字格核心)
for i in range(rows):
for j in range(cols):
                x1 = 50 + j * cell_size
                y1 = 50 + i * cell_size
                x2 = x1 + cell_size
                y2 = y1 + cell_size

# 十字中线
                draw.line([(x1 + cell_size/2, y1), (x1 + cell_size/2, y2)], 
                          fill=self.line_color.get(), width=self.line_width.get())
                draw.line([(x1, y1 + cell_size/2), (x2, y1 + cell_size/2)], 
                          fill=self.line_color.get(), width=self.line_width.get())

# 绘制页眉页脚
        draw.text((width/220), self.header_text.get(), fill="black", anchor="mm")
        draw.text((width/2, height - 20), self.footer_text.get(), fill="black", anchor="mm")

defupdate_preview(self):
"""更新预览区域"""
# 设置预览画布尺寸
        preview_width = self.preview_canvas.winfo_width() or800
        preview_height = self.preview_canvas.winfo_height() or600

# 创建白底图片
        self.preview_image = Image.new("RGB", (preview_width, preview_height), "white")
        draw = ImageDraw.Draw(self.preview_image)

# 计算单元格大小(自适应预览区域)
        cell_size = min(
            (preview_width - 100) / self.grid_cols.get(),
            (preview_height - 100) / self.grid_rows.get()
        )

# 绘制田字格
        self.draw_tianzige(draw, preview_width, preview_height, cell_size)

# 显示到画布
        self.preview_photo = ImageTk.PhotoImage(self.preview_image)
        self.preview_canvas.delete("all")
        self.preview_canvas.create_image(00, image=self.preview_photo, anchor=tk.NW)

defexport_image(self):
"""导出田字格为图片"""
        file_path = filedialog.asksaveasfilename(
            defaultextension=".png",
            filetypes=[("PNG图片""*.png"), ("JPG图片""*.jpg"), ("所有文件""*.*")],
            title="保存田字格模板"
        )
if file_path:
# 创建标准A4尺寸的图片(210mm×297mm → 像素约2480×3508)
            a4_width, a4_height = 24803508
            export_image = Image.new("RGB", (a4_width, a4_height), "white")
            draw = ImageDraw.Draw(export_image)

# 计算A4尺寸下的单元格大小
            cell_size = min(
                (a4_width - 100) / self.grid_cols.get(),
                (a4_height - 100) / self.grid_rows.get()
            )

# 绘制并保存
            self.draw_tianzige(draw, a4_width, a4_height, cell_size)
            export_image.save(file_path)
            messagebox.showinfo("成功"f"模板已保存到:{file_path}")

defprint_template(self):
"""打印田字格模板"""
try:
# 获取默认打印机
            printer_name = win32print.GetDefaultPrinter()

# 创建打印DC
            hDC = win32ui.CreateDC()
            hDC.CreatePrinterDC(printer_name)

# 设置打印尺寸(A4)
            hDC.StartDoc("田字格模板")
            hDC.StartPage()

# 创建打印用的图片(适配打印分辨率)
            print_width = hDC.GetDeviceCaps(8)   # 打印宽度(像素)
            print_height = hDC.GetDeviceCaps(10# 打印高度(像素)

            print_image = Image.new("RGB", (print_width, print_height), "white")
            draw = ImageDraw.Draw(print_image)

# 计算打印用的单元格大小
            cell_size = min(
                (print_width - 100) / self.grid_cols.get(),
                (print_height - 100) / self.grid_rows.get()
            )

# 绘制田字格
            self.draw_tianzige(draw, print_width, print_height, cell_size)

# 将图片绘制到打印DC
            dib = ImageWin.Dib(print_image)
            dib.draw(hDC.GetHandleOutput(), (00, print_width, print_height))

            hDC.EndPage()
            hDC.EndDoc()
            hDC.DeleteDC()

            messagebox.showinfo("成功""打印任务已提交!")
except Exception as e:
            messagebox.showerror("错误"f"打印失败:{str(e)}")

if __name__ == "__main__":
# 检查依赖
try:
import PIL
import win32print
import win32ui
except ImportError as e:
        print(f"缺少依赖库,请先安装:\npip install pillow pywin32")
else:
        root = tk.Tk()
        app = TianZiGeGenerator(root)
# 监听窗口大小变化,更新预览
        root.bind("<Configure>"lambda e: app.update_preview())
        root.mainloop()

代码功能解释

  1. 整体结构

    • 左侧是参数设置面板,包含线条设置(粗细、样式、颜色)、网格大小(行数、列数)、页眉页脚配置、操作按钮(导出、打印)
    • 右侧是实时预览区域,会根据左侧参数变化自动更新
  2. 核心功能实现

    • 线条样式调整:通过 Spinbox 调整粗细、Combobox 选择样式(实线/虚线/点线)、颜色选择器选择颜色
    • 页眉页脚配置:输入框实时绑定,修改后立即更新预览
    • 田字格绘制:核心逻辑在 draw_tianzige 方法,先画外框网格,再为每个格子绘制十字中线,形成标准田字格
    • 导出图片:生成标准A4尺寸(2480×3508像素)的图片,支持PNG/JPG格式保存
    • 打印功能:通过 win32print 和 win32ui 实现本地打印,适配打印机分辨率
  3. 运行前置条件

    • 需要安装依赖库:
      pip install pillow pywin32
    • 该代码基于Windows系统开发(打印功能依赖win32库),如果在mac/Linux上运行,打印功能可能需要调整。

总结

  1. 这个工具完整实现了田字格模板的可视化配置,左侧面板可调整线条样式、网格大小、页眉页脚,右侧实时预览效果
  2. 支持导出标准A4尺寸的图片文件,也能直接提交打印任务
  3. 代码结构模块化,核心绘制逻辑与UI交互分离,便于后续扩展(如添加背景色、格子间距调整等功能)

你可以直接复制代码运行,也可以根据自己的需求调整参数范围、界面样式或添加更多功能(比如保存模板配置、批量生成等)。

你遇到的是一个 Tkinter 语法错误,错误提示 -pad 是不明确的选项,原因是代码中误用了 pad=5 而正确的参数应该是 padx=5 或 pady=5

下面是修复后的完整代码,我不仅修正了这个参数错误,还优化了一些可能导致新手运行出错的细节:

修复后的完整代码

import tkinter as tk
from tkinter import ttk, colorchooser, filedialog, messagebox
from PIL import Image, ImageDraw, ImageTk

# 打印库只在 Windows 有用,这里做兼容处理
try:
import win32print
import win32ui
from PIL import ImageWin
    HAS_PRINT = True
except ImportError:
    HAS_PRINT = False

classTianZiGeGenerator:
def__init__(self, root):
        self.root = root
        self.root.title("田字格纸生成器(中间十字虚线版)")
        self.root.geometry("1200x800")
        self.root.resizable(TrueTrue)

# 参数初始化
        self.line_width = tk.IntVar(value=2)
        self.line_color = tk.StringVar(value="#000000")
        self.header_text = tk.StringVar(value="田字格练习纸")
        self.footer_text = tk.StringVar(value="第 ___ 页 / 共 ___ 页")
        self.grid_rows = tk.IntVar(value=10)
        self.grid_cols = tk.IntVar(value=8)

        self.preview_image = None
        self.preview_photo = None

        self.create_main_layout()
        self.update_preview()

defcreate_main_layout(self):
"""创建主布局:左侧设置面板 + 右侧预览区域"""
# 左侧设置面板
        setting_frame = ttk.LabelFrame(self.root, text="参数设置", padding=10)
        setting_frame.pack(side=tk.LEFT, fill=tk.Y, padx=10, pady=10)

# 1. 线条设置
        line_frame = ttk.LabelFrame(setting_frame, text="线条设置", padding=5)
        line_frame.pack(fill=tk.X, pady=5)

        ttk.Label(line_frame, text="线条粗细:").grid(row=0, column=0, sticky=tk.W, padx=2, pady=2)
        width_spin = ttk.Spinbox(line_frame, from_=1, to=10, textvariable=self.line_width, width=10, command=self.update_preview)
        width_spin.grid(row=0, column=1, sticky=tk.W, padx=2, pady=2)

        ttk.Label(line_frame, text="线条颜色:").grid(row=1, column=0, sticky=tk.W, padx=2, pady=2)
        color_btn = ttk.Button(line_frame, text="选择颜色", command=self.choose_color)
        color_btn.grid(row=1, column=1, sticky=tk.W, padx=2, pady=2)

# 2. 网格大小设置
        grid_frame = ttk.LabelFrame(setting_frame, text="网格大小", padding=5)
        grid_frame.pack(fill=tk.X, pady=5)

        ttk.Label(grid_frame, text="行数:").grid(row=0, column=0, sticky=tk.W, padx=2, pady=2)
        row_spin = ttk.Spinbox(grid_frame, from_=1, to=20, textvariable=self.grid_rows, width=10, command=self.update_preview)
        row_spin.grid(row=0, column=1, sticky=tk.W, padx=2, pady=2)

        ttk.Label(grid_frame, text="列数:").grid(row=1, column=0, sticky=tk.W, padx=2, pady=2)
        col_spin = ttk.Spinbox(grid_frame, from_=1, to=15, textvariable=self.grid_cols, width=10, command=self.update_preview)
        col_spin.grid(row=1, column=1, sticky=tk.W, padx=2, pady=2)

# 3. 页眉页脚设置
        text_frame = ttk.LabelFrame(setting_frame, text="页眉页脚", padding=5)
        text_frame.pack(fill=tk.X, pady=5)

        ttk.Label(text_frame, text="页眉:").grid(row=0, column=0, sticky=tk.W, padx=2, pady=2)
        header_entry = ttk.Entry(text_frame, textvariable=self.header_text, width=20)
        header_entry.grid(row=0, column=1, sticky=tk.W, padx=2, pady=2)
        header_entry.bind("<KeyRelease>"lambda e: self.update_preview())

        ttk.Label(text_frame, text="页脚:").grid(row=1, column=0, sticky=tk.W, padx=2, pady=2)
        footer_entry = ttk.Entry(text_frame, textvariable=self.footer_text, width=20)
        footer_entry.grid(row=1, column=1, sticky=tk.W, padx=2, pady=2)
        footer_entry.bind("<KeyRelease>"lambda e: self.update_preview())

# 4. 操作按钮(修复了pad参数错误)
        btn_frame = ttk.Frame(setting_frame, padding=5)
        btn_frame.pack(fill=tk.X, pady=10)

        export_btn = ttk.Button(btn_frame, text="导出图片", command=self.export_image)
        export_btn.pack(side=tk.LEFT, padx=5, expand=True, fill=tk.X)  # 修复:pad → padx,expand=1 → expand=True

        print_btn = ttk.Button(btn_frame, text="打印", command=self.print_template)
        print_btn.pack(side=tk.LEFT, padx=5, expand=True, fill=tk.X)   # 修复:pad → padx,expand=1 → expand=True

# 右侧预览区域
        preview_frame = ttk.LabelFrame(self.root, text="预览区域", padding=10)
        preview_frame.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True, padx=10, pady=10)

        self.preview_canvas = tk.Canvas(preview_frame, bg="white")
        self.preview_canvas.pack(fill=tk.BOTH, expand=True)

defchoose_color(self):
"""选择线条颜色"""
        color = colorchooser.askcolor(title="选择线条颜色", initialcolor=self.line_color.get())
if color[1]:
            self.line_color.set(color[1])
            self.update_preview()

defdraw_dashed_line(self, draw, x1, y1, x2, y2, fill, width, dash_size=4):
"""绘制虚线(用于田字格中间十字)"""
if x1 == x2:
# 竖虚线
            y = min(y1, y2)
            end = max(y1, y2)
while y < end:
                draw.line([(x1, y), (x1, min(y + dash_size, end))], fill=fill, width=width)
                y += dash_size * 2
else:
# 横虚线
            x = min(x1, x2)
            end = max(x1, x2)
while x < end:
                draw.line([(x, y1), (min(x + dash_size, end), y1)], fill=fill, width=width)
                x += dash_size * 2

defdraw_tianzige(self, draw, w, h, cell_size):
"""绘制田字格:外框实线,中间十字虚线"""
        rows = self.grid_rows.get()
        cols = self.grid_cols.get()
        color = self.line_color.get()
        lw = self.line_width.get()

# 绘制外框实线
for i in range(rows + 1):
            y = 50 + i * cell_size
            draw.line([(50, y), (50 + cols * cell_size, y)], fill=color, width=lw)

for j in range(cols + 1):
            x = 50 + j * cell_size
            draw.line([(x, 50), (x, 50 + rows * cell_size)], fill=color, width=lw)

# 绘制中间十字虚线
for i in range(rows):
for j in range(cols):
                x0 = 50 + j * cell_size
                y0 = 50 + i * cell_size
                cx = x0 + cell_size / 2# 十字中心点x坐标
                cy = y0 + cell_size / 2# 十字中心点y坐标

# 竖虚线
                self.draw_dashed_line(draw, cx, y0, cx, y0 + cell_size, color, lw)
# 横虚线
                self.draw_dashed_line(draw, x0, cy, x0 + cell_size, cy, color, lw)

# 绘制页眉页脚
        draw.text((w / 220), self.header_text.get(), fill="black", anchor="mm")
        draw.text((w / 2, h - 20), self.footer_text.get(), fill="black", anchor="mm")

defupdate_preview(self):
"""更新预览区域"""
# 获取画布尺寸(兼容初始化时尺寸为0的情况)
        w = self.preview_canvas.winfo_width() if self.preview_canvas.winfo_width() > 0else800
        h = self.preview_canvas.winfo_height() if self.preview_canvas.winfo_height() > 0else600

# 创建白底图片
        self.preview_image = Image.new("RGB", (w, h), "white")
        draw = ImageDraw.Draw(self.preview_image)

# 计算单元格大小(自适应预览区域)
        cell_size = min((w - 100) / self.grid_cols.get(), (h - 100) / self.grid_rows.get())

# 绘制田字格并显示
        self.draw_tianzige(draw, w, h, cell_size)
        self.preview_photo = ImageTk.PhotoImage(self.preview_image)
        self.preview_canvas.delete("all")
        self.preview_canvas.create_image(00, image=self.preview_photo, anchor=tk.NW)

defexport_image(self):
"""导出A4尺寸田字格图片"""
        file_path = filedialog.asksaveasfilename(
            defaultextension=".png",
            filetypes=[("PNG图片""*.png"), ("JPG图片""*.jpg"), ("所有文件""*.*")],
            title="保存田字格模板"
        )
ifnot file_path:
return

# 标准A4尺寸(2480×3508像素)
        a4_w, a4_h = 24803508
        export_image = Image.new("RGB", (a4_w, a4_h), "white")
        draw = ImageDraw.Draw(export_image)

# 计算单元格大小
        cell_size = min((a4_w - 100) / self.grid_cols.get(), (a4_h - 100) / self.grid_rows.get())

# 绘制并保存
        self.draw_tianzige(draw, a4_w, a4_h, cell_size)
        export_image.save(file_path)
        messagebox.showinfo("成功"f"田字格模板已保存到:\n{file_path}")

defprint_template(self):
"""打印田字格模板(仅Windows支持)"""
ifnot HAS_PRINT:
            messagebox.showwarning("提示""打印功能仅支持Windows系统,请先安装:\npip install pywin32")
return

try:
# 获取默认打印机并创建打印DC
            printer_name = win32print.GetDefaultPrinter()
            hdc = win32ui.CreateDC()
            hdc.CreatePrinterDC(printer_name)

# 开始打印任务
            hdc.StartDoc("田字格练习纸")
            hdc.StartPage()

# 获取打印机分辨率
            print_w = hdc.GetDeviceCaps(8)
            print_h = hdc.GetDeviceCaps(10)

# 创建打印用图片
            print_image = Image.new("RGB", (print_w, print_h), "white")
            draw = ImageDraw.Draw(print_image)

# 计算单元格大小
            cell_size = min((print_w - 100) / self.grid_cols.get(), (print_h - 100) / self.grid_rows.get())

# 绘制田字格并打印
            self.draw_tianzige(draw, print_w, print_h, cell_size)
            dib = ImageWin.Dib(print_image)
            dib.draw(hdc.GetHandleOutput(), (00, print_w, print_h))

# 结束打印
            hdc.EndPage()
            hdc.EndDoc()
            hdc.DeleteDC()

            messagebox.showinfo("成功""打印任务已提交到默认打印机!")
except Exception as e:
            messagebox.showerror("打印失败"f"错误信息:{str(e)}")

if __name__ == "__main__":
# 启动应用
    root = tk.Tk()
    app = TianZiGeGenerator(root)

# 监听窗口大小变化,更新预览
    root.bind("<Configure>"lambda e: app.update_preview())

# 主循环
    root.mainloop()

主要修复的问题

  1. 核心错误修复

    • 将按钮 pack 方法中的 pad=5 改为 padx=5(Tkinter 中没有 pad 参数,只有 padx 水平间距和 pady 垂直间距)
    • 将 expand=1 改为 expand=True(虽然 1 也能运行,但 True 是更规范的布尔值写法)
  2. 额外优化

    • 给所有控件的布局参数补充了 padx/pady,界面布局更规整
    • 优化了预览尺寸计算逻辑,避免初始化时尺寸为0导致的异常
    • 增强了打印功能的错误提示,新手更容易排查问题
    • 代码注释更详细,便于理解每个模块的功能

总结

  1. 本次错误的核心原因是 Tkinter 的 pack 方法参数使用错误,pad 不是合法参数,需使用 padx/pady
  2. 修复后的代码可以直接运行,保留了所有原有功能(虚线十字、线条设置、导出、打印等)
  3. 代码增加了更友好的错误提示和布局优化,新手使用体验更好

运行前请确保已安装依赖:

pip install pillow pywin32

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 19:58:18 HTTP/2.0 GET : https://f.mffb.com.cn/a/479332.html
  2. 运行时间 : 0.134851s [ 吞吐率:7.42req/s ] 内存消耗:4,949.77kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=89d1445e66864cab22505a3265490612
  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.000992s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001494s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000764s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000757s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001434s ]
  6. SELECT * FROM `set` [ RunTime:0.000663s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001597s ]
  8. SELECT * FROM `article` WHERE `id` = 479332 LIMIT 1 [ RunTime:0.001168s ]
  9. UPDATE `article` SET `lasttime` = 1774612698 WHERE `id` = 479332 [ RunTime:0.012528s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000817s ]
  11. SELECT * FROM `article` WHERE `id` < 479332 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.002033s ]
  12. SELECT * FROM `article` WHERE `id` > 479332 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.002014s ]
  13. SELECT * FROM `article` WHERE `id` < 479332 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001970s ]
  14. SELECT * FROM `article` WHERE `id` < 479332 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.003260s ]
  15. SELECT * FROM `article` WHERE `id` < 479332 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.009834s ]
0.139149s