最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于Python開發(fā)一個小說圖片PDF生成器

 更新時間:2025年10月09日 09:18:38   作者:winfredzhang  
本項目是一個基于 wxPython 開發(fā)的桌面應(yīng)用程序,用于將圖片和文字描述組合生成精美的 PDF 小說,它解決了創(chuàng)作者需要將圖文內(nèi)容快速整理成電子書的需求,特別適合繪本、圖文小說、攝影作品集等場景,需要的朋友可以參考下

項目概述

本項目是一個基于 wxPython 開發(fā)的桌面應(yīng)用程序,用于將圖片和文字描述組合生成精美的 PDF 小說。它解決了創(chuàng)作者需要將圖文內(nèi)容快速整理成電子書的需求,特別適合繪本、圖文小說、攝影作品集等場景。

核心功能

  • 批量導(dǎo)入和管理圖片
  • 為圖片添加場景描述
  • 支持一段文字對應(yīng)多張圖片
  • 智能布局算法,將文字和配圖顯示在同一頁
  • 自動生成帶封面的 PDF 文件

技術(shù)架構(gòu)

依賴庫分析

import wx                    # GUI框架
import json                  # 數(shù)據(jù)持久化
import os                    # 文件系統(tǒng)操作
from pathlib import Path     # 路徑處理
from reportlab.lib.pagesizes import A4        # PDF頁面尺寸
from reportlab.pdfgen import canvas           # PDF畫布
from reportlab.lib.utils import ImageReader   # 圖片讀取
from reportlab.pdfbase import pdfmetrics      # 字體管理
from reportlab.pdfbase.ttfonts import TTFont  # TrueType字體
from PIL import Image        # 圖片處理
import math                  # 數(shù)學(xué)計算

技術(shù)棧選擇理由:

  • wxPython:跨平臺GUI框架,原生界面風格,性能優(yōu)秀
  • ReportLab:強大的PDF生成庫,支持精確的頁面控制
  • Pillow (PIL):圖片處理標準庫,用于圖片縮放和格式轉(zhuǎn)換
  • JSON:輕量級數(shù)據(jù)格式,便于項目保存和加載

核心數(shù)據(jù)結(jié)構(gòu)

ImageItem 類

class ImageItem:
    """圖片項數(shù)據(jù)類"""
    def __init__(self, path, description="", group_id=None):
        self.path = path              # 圖片文件路徑
        self.description = description # 場景描述文字
        self.group_id = group_id      # 分組ID(相同ID表示同一組)

設(shè)計思路:

  • 使用 group_id 實現(xiàn)多張圖片共享同一段描述的功能
  • 通過時間戳生成唯一ID,避免沖突
  • 簡潔的數(shù)據(jù)結(jié)構(gòu)便于序列化為JSON

GUI 界面設(shè)計

布局結(jié)構(gòu)

程序采用左右分欄布局

┌─────────────────────────────────────────┐
│           小說名稱輸入框                 │
├──────────────┬──────────────────────────┤
│  左側(cè)區(qū)域    │      右側(cè)區(qū)域             │
│  ┌────────┐ │  ┌──────────────────┐    │
│  │操作按鈕│ │  │  圖片預(yù)覽區(qū)域    │    │
│  ├────────┤ │  └──────────────────┘    │
│  │圖片列表│ │  ┌──────────────────┐    │
│  │        │ │  │  場景描述輸入    │    │
│  │        │ │  └──────────────────┘    │
│  │        │ │  [圖片數(shù)量] [操作按鈕]   │
│  └────────┘ │                           │
└──────────────┴──────────────────────────┘

關(guān)鍵UI組件

1. 標題輸入?yún)^(qū)

title_sizer = wx.BoxSizer(wx.HORIZONTAL)
title_label = wx.StaticText(panel, label='小說名稱:')
self.title_text = wx.TextCtrl(panel, size=(300, -1))

用于輸入小說標題,會顯示在PDF封面頁。

2. 圖片列表框

self.image_listbox = wx.ListBox(panel, style=wx.LB_SINGLE)
  • 使用 wx.LB_SINGLE 單選模式
  • 動態(tài)顯示文件名和描述預(yù)覽
  • 綁定點擊事件觸發(fā)圖片預(yù)覽

3. 圖片預(yù)覽區(qū)

self.image_preview = wx.StaticBitmap(panel, size=(450, 350))
self.image_preview.SetBackgroundColour(wx.Colour(240, 240, 240))

使用 StaticBitmap 組件顯示選中的圖片,設(shè)置灰色背景便于識別。

4. 分組控制

self.group_spin = wx.SpinCtrl(panel, value='1', min=1, max=50, initial=1)

SpinCtrl 數(shù)字調(diào)節(jié)器,用戶可以指定當前描述對應(yīng)的圖片數(shù)量(1-50張)。

核心功能實現(xiàn)

1. 圖片管理

批量添加文件夾

def on_add_folder(self, event):
    """添加文件夾中的所有圖片"""
    dlg = wx.DirDialog(self, "選擇圖片文件夾")
    if dlg.ShowModal() == wx.ID_OK:
        folder_path = dlg.GetPath()
        image_extensions = ('.jpg', '.jpeg', '.png', '.bmp', '.gif')
        
        for file in sorted(os.listdir(folder_path)):
            if file.lower().endswith(image_extensions):
                full_path = os.path.join(folder_path, file)
                self.add_image_item(full_path)
        
        self.update_listbox()
    dlg.Destroy()

關(guān)鍵點:

  • 使用 sorted() 確保文件按名稱排序
  • lower().endswith() 不區(qū)分大小寫匹配擴展名
  • 必須調(diào)用 dlg.Destroy() 釋放對話框資源

單張/多張?zhí)砑?/h4>
def on_add_image(self, event):
    """添加單張圖片"""
    wildcard = "圖片文件 (*.jpg;*.jpeg;*.png;*.bmp;*.gif)|*.jpg;*.jpeg;*.png;*.bmp;*.gif"
    dlg = wx.FileDialog(self, "選擇圖片", wildcard=wildcard, 
                       style=wx.FD_OPEN | wx.FD_MULTIPLE)
    
    if dlg.ShowModal() == wx.ID_OK:
        paths = dlg.GetPaths()  # 獲取多個路徑
        for path in paths:
            self.add_image_item(path)
        self.update_listbox()
    dlg.Destroy()

使用 wx.FD_MULTIPLE 標志支持多選,GetPaths() 返回路徑列表。

2. 圖片預(yù)覽功能

def show_preview(self, image_path):
    """顯示圖片預(yù)覽"""
    try:
        img = Image.open(image_path)
        
        # 調(diào)整圖片大小以適應(yīng)預(yù)覽區(qū)域
        preview_size = (450, 350)
        img.thumbnail(preview_size, Image.Resampling.LANCZOS)
        
        # 轉(zhuǎn)換為wx.Bitmap
        width, height = img.size
        wx_img = wx.Image(width, height)
        wx_img.SetData(img.convert("RGB").tobytes())
        bitmap = wx.Bitmap(wx_img)
        
        self.image_preview.SetBitmap(bitmap)
        
    except Exception as e:
        wx.MessageBox(f"無法加載圖片:{str(e)}", "錯誤", wx.OK | wx.ICON_ERROR)

技術(shù)細節(jié):

  • thumbnail() 方法保持寬高比縮放
  • LANCZOS 重采樣算法提供最佳縮放質(zhì)量
  • PIL Image → wx.Image → wx.Bitmap 的轉(zhuǎn)換鏈
  • 必須轉(zhuǎn)換為RGB模式(去除Alpha通道)

3. 圖片順序調(diào)整

上移實現(xiàn)

def on_move_up(self, event):
    """上移圖片"""
    selection = self.image_listbox.GetSelection()
    if selection > 0:
        # Python交換語法
        self.image_items[selection], self.image_items[selection-1] = \
            self.image_items[selection-1], self.image_items[selection]
        self.update_listbox()
        self.image_listbox.SetSelection(selection-1)

設(shè)計要點:

  • 檢查邊界條件(不能上移第一項)
  • 使用Python優(yōu)雅的元組解包交換
  • 更新后保持選中狀態(tài)

4. 描述分組功能

def on_save_description(self, event):
    """保存描述到當前及后續(xù)指定數(shù)量的圖片"""
    selection = self.image_listbox.GetSelection()
    if selection != wx.NOT_FOUND:
        description = self.description_text.GetValue()
        group_count = self.group_spin.GetValue()
        
        # 生成唯一的組ID
        import time
        group_id = int(time.time() * 1000)  # 毫秒級時間戳
        
        # 為當前及后續(xù)圖片設(shè)置相同的描述和組ID
        for i in range(selection, min(selection + group_count, len(self.image_items))):
            self.image_items[i].description = description
            self.image_items[i].group_id = group_id
        
        self.update_listbox()
        self.save_to_json()
        wx.MessageBox(f"描述已保存到 {group_count} 張圖片!", "提示", wx.OK | wx.ICON_INFORMATION)

核心邏輯:

  1. 生成毫秒級時間戳作為唯一組ID
  2. 從選中位置開始,連續(xù)設(shè)置指定數(shù)量的圖片
  3. 使用 min() 防止越界
  4. 相同 group_id 的圖片會在PDF中顯示在同一頁

5. 數(shù)據(jù)持久化

保存到JSON

def save_to_json(self):
    """保存所有數(shù)據(jù)到JSON"""
    data = {
        'novel_title': self.title_text.GetValue(),
        'images': []
    }
    
    for item in self.image_items:
        data['images'].append({
            'path': item.path,
            'description': item.description,
            'group_id': item.group_id
        })
    
    json_path = 'novel_data.json'
    with open(json_path, 'w', encoding='utf-8') as f:
        json.dump(data, f, ensure_ascii=False, indent=2)

JSON結(jié)構(gòu)示例:

{
  "novel_title": "時光旅行者",
  "images": [
    {
      "path": "/path/to/image1.jpg",
      "description": "主角在未來城市中醒來",
      "group_id": 1696834567890
    },
    {
      "path": "/path/to/image2.jpg",
      "description": "主角在未來城市中醒來",
      "group_id": 1696834567890
    }
  ]
}

從JSON加載

def on_load_json(self, event):
    """從JSON加載數(shù)據(jù)"""
    wildcard = "JSON文件 (*.json)|*.json"
    dlg = wx.FileDialog(self, "選擇JSON文件", wildcard=wildcard, style=wx.FD_OPEN)
    
    if dlg.ShowModal() == wx.ID_OK:
        json_path = dlg.GetPath()
        try:
            with open(json_path, 'r', encoding='utf-8') as f:
                data = json.load(f)
            
            self.image_items.clear()
            
            if 'novel_title' in data:
                self.title_text.SetValue(data['novel_title'])
            
            for img_data in data.get('images', []):
                if os.path.exists(img_data['path']):  # 驗證文件存在
                    item = ImageItem(
                        img_data['path'],
                        img_data.get('description', ''),
                        img_data.get('group_id')
                    )
                    self.image_items.append(item)
            
            self.update_listbox()
            wx.MessageBox("JSON文件加載成功!", "提示", wx.OK | wx.ICON_INFORMATION)
            
        except Exception as e:
            wx.MessageBox(f"加載JSON失?。簕str(e)}", "錯誤", wx.OK | wx.ICON_ERROR)
    
    dlg.Destroy()

安全性考慮:

  • 檢查文件路徑是否存在
  • 使用 get() 方法提供默認值
  • 完整的異常處理機制

PDF生成核心算法

1. PDF創(chuàng)建流程

def create_pdf(self, pdf_path):
    """創(chuàng)建PDF文件"""
    c = canvas.Canvas(pdf_path, pagesize=A4)
    page_width, page_height = A4
    
    # 注冊中文字體
    try:
        pdfmetrics.registerFont(TTFont('SimSun', 'simsun.ttc'))
        font_name = 'SimSun'
    except:
        try:
            pdfmetrics.registerFont(TTFont('SimSun', '/System/Library/Fonts/STHeiti Light.ttc'))
            font_name = 'SimSun'
        except:
            font_name = 'Helvetica'
    
    # 創(chuàng)建封面頁
    if self.novel_title:
        c.setFont(font_name, 36)
        title_width = c.stringWidth(self.novel_title, font_name, 36)
        c.drawString((page_width - title_width) / 2, page_height / 2, self.novel_title)
        c.showPage()
    
    # 按組處理內(nèi)容...

字體處理策略:

  1. 優(yōu)先嘗試Windows字體(simsun.ttc)
  2. 其次嘗試macOS字體(STHeiti)
  3. 最后回退到默認字體(Helvetica)
  4. 使用 stringWidth() 計算文字寬度實現(xiàn)居中

2. 圖片分組處理

# 按組處理圖片
processed_indices = set()

for i, item in enumerate(self.image_items):
    if i in processed_indices:
        continue
    
    # 收集同組的圖片
    if item.group_id is not None:
        group_images = [img for j, img in enumerate(self.image_items) 
                       if img.group_id == item.group_id]
        for j, img in enumerate(self.image_items):
            if img.group_id == item.group_id:
                processed_indices.add(j)
    else:
        group_images = [item]
        processed_indices.add(i)
    
    # 在一頁中顯示文字和所有配圖
    self.draw_content_page(c, item.description, group_images, 
                          page_width, page_height, font_name)
    c.showPage()

算法解析:

  • 使用 set 記錄已處理的圖片索引,避免重復(fù)處理
  • 通過 group_id 識別同組圖片
  • 列表推導(dǎo)式高效收集同組圖片
  • 每組內(nèi)容調(diào)用 draw_content_page() 渲染到一頁

3. 智能布局算法

這是整個項目最復(fù)雜也最精彩的部分:

def draw_content_page(self, c, description, images, page_width, page_height, font_name):
    """在一頁中繪制文字描述和配圖"""
    margin = 40
    usable_width = page_width - 2 * margin
    usable_height = page_height - 2 * margin
    
    current_y = page_height - margin
    
    # 1. 繪制文字描述
    if description:
        c.setFont(font_name, 12)
        lines = self.wrap_text(description, usable_width - 10, c, font_name, 12)
        
        for line in lines:
            current_y -= 18
            c.drawString(margin + 5, current_y, line)
        
        current_y -= 20  # 文字和圖片之間的間距
    
    # 2. 計算剩余空間
    remaining_height = current_y - margin
    
    if len(images) == 0:
        return
    
    num_images = len(images)
    
    # 3. 根據(jù)圖片數(shù)量選擇布局策略
    if num_images == 1:
        # 單張圖片:居中顯示
        self.draw_single_image(c, images[0].path, margin, margin, 
                              usable_width, remaining_height)
    
    elif num_images == 2:
        # 兩張圖片:并排顯示
        img_width = (usable_width - 20) / 2
        for idx, img in enumerate(images):
            x = margin + idx * (img_width + 20)
            self.draw_single_image(c, img.path, x, margin, 
                                  img_width, remaining_height)
    
    elif num_images == 3:
        # 三張圖片:動態(tài)布局
        if remaining_height > usable_width * 0.8:
            # 空間充足:上1下2布局
            top_height = remaining_height * 0.5
            bottom_height = remaining_height * 0.45
            
            self.draw_single_image(c, images[0].path, margin, 
                                  margin + bottom_height + 20, 
                                  usable_width, top_height)
            
            img_width = (usable_width - 20) / 2
            for idx, img in enumerate(images[1:]):
                x = margin + idx * (img_width + 20)
                self.draw_single_image(c, img.path, x, margin, 
                                      img_width, bottom_height)
        else:
            # 空間不足:三張并排
            img_width = (usable_width - 40) / 3
            for idx, img in enumerate(images):
                x = margin + idx * (img_width + 20)
                self.draw_single_image(c, img.path, x, margin, 
                                      img_width, remaining_height)
    
    elif num_images == 4:
        # 四張圖片:2x2網(wǎng)格
        img_width = (usable_width - 20) / 2
        img_height = (remaining_height - 20) / 2
        
        positions = [
            (0, 1), (1, 1),  # 上排
            (0, 0), (1, 0)   # 下排
        ]
        
        for idx, img in enumerate(images):
            col, row = positions[idx]
            x = margin + col * (img_width + 20)
            y = margin + row * (img_height + 20)
            self.draw_single_image(c, img.path, x, y, img_width, img_height)
    
    else:
        # 5張及以上:自動網(wǎng)格布局
        cols = min(3, num_images)
        rows = math.ceil(num_images / cols)
        
        img_width = (usable_width - (cols - 1) * 15) / cols
        img_height = (remaining_height - (rows - 1) * 15) / rows
        
        for idx, img in enumerate(images):
            row = idx // cols
            col = idx % cols
            x = margin + col * (img_width + 15)
            y = margin + (rows - 1 - row) * (img_height + 15)
            self.draw_single_image(c, img.path, x, y, img_width, img_height)

布局策略詳解:

單圖布局(1張)

┌─────────────────┐
│   文字描述      │
├─────────────────┤
│                 │
│   [單張大圖]    │
│                 │
└─────────────────┘

充分利用剩余空間,圖片居中顯示。

雙圖布局(2張)

┌─────────────────┐
│   文字描述      │
├────────┬────────┤
│        │        │
│ [圖1]  │ [圖2]  │
│        │        │
└────────┴────────┘

左右并排,平分空間。

三圖布局(3張)

根據(jù)剩余空間自適應(yīng):

空間充足時(高度 > 寬度 * 0.8):

┌─────────────────┐
│   文字描述      │
├─────────────────┤
│    [圖片1]      │
├────────┬────────┤
│ [圖2]  │ [圖3]  │
└────────┴────────┘

空間不足時:

┌─────────────────┐
│   文字描述      │
├─────┬─────┬─────┤
│[圖1]│[圖2]│[圖3]│
└─────┴─────┴─────┘

四圖布局(4張)

┌─────────────────┐
│   文字描述      │
├────────┬────────┤
│ [圖1]  │ [圖2]  │
├────────┼────────┤
│ [圖3]  │ [圖4]  │
└────────┴────────┘

標準2x2網(wǎng)格。

多圖布局(5+張)

┌──────────────────────┐
│     文字描述         │
├──────┬──────┬────────┤
│[圖1] │[圖2] │ [圖3]  │
├──────┼──────┼────────┤
│[圖4] │[圖5] │ [圖6]  │
└──────┴──────┴────────┘

自動計算網(wǎng)格(最多3列),向上取整行數(shù)。

4. 單圖繪制函數(shù)

def draw_single_image(self, c, image_path, x, y, max_width, max_height):
    """在指定位置繪制單張圖片"""
    try:
        img = Image.open(image_path)
        img_width, img_height = img.size
        
        # 計算縮放比例(保持寬高比)
        scale = min(max_width / img_width, max_height / img_height)
        new_width = img_width * scale
        new_height = img_height * scale
        
        # 居中對齊
        x_centered = x + (max_width - new_width) / 2
        y_centered = y + (max_height - new_height) / 2
        
        c.drawImage(image_path, x_centered, y_centered, 
                   width=new_width, height=new_height)
        
    except Exception as e:
        print(f"繪制圖片 {image_path} 時出錯:{str(e)}")

關(guān)鍵算法:

  • scale = min(width_ratio, height_ratio) 確保圖片不超出邊界
  • 居中算法:centered = start + (available - actual) / 2
  • 異常處理確保單張圖片失敗不影響整體生成

5. 文字換行算法

def wrap_text(self, text, max_width, canvas_obj, font_name, font_size):
    """文字換行"""
    lines = []
    paragraphs = text.split('\n')
    
    for para in paragraphs:
        if not para.strip():
            lines.append('')
            continue
            
        current_line = ""
        for char in para:
            test_line = current_line + char
            if canvas_obj.stringWidth(test_line, font_name, font_size) < max_width:
                current_line = test_line
            else:
                if current_line:
                    lines.append(current_line)
                current_line = char
        
        if current_line:
            lines.append(current_line)
    
    return lines

算法特點:

  • 支持段落(\n)保留
  • 逐字符測量寬度,精確換行
  • 使用 stringWidth() 考慮不同字符寬度(中英文混排)
  • 空段落保留為空行

性能優(yōu)化與最佳實踐

1. 內(nèi)存管理

# 使用 thumbnail 而非 resize
img.thumbnail(preview_size, Image.Resampling.LANCZOS)

thumbnail() 直接修改原對象,比 resize() 返回新對象更節(jié)省內(nèi)存。

2. 資源釋放

dlg = wx.FileDialog(...)
if dlg.ShowModal() == wx.ID_OK:
    # 處理邏輯
dlg.Destroy()  # 必須顯式銷毀

wxPython 對話框必須手動銷毀,否則會內(nèi)存泄漏。

3. 異常處理

所有文件操作和圖片處理都包裹在 try-except 中,確保程序穩(wěn)定性。

4. 用戶體驗優(yōu)化

  • 操作后立即提供反饋(MessageBox)
  • 保持選中狀態(tài)(移動后重新選中)
  • 列表顯示描述預(yù)覽(快速識別)

可能的擴展功能

1. 圖片編輯

  • 添加濾鏡效果
  • 裁剪和旋轉(zhuǎn)
  • 亮度、對比度調(diào)整

2. 文字排版

  • 支持富文本(粗體、斜體)
  • 自定義字體和字號
  • 段落對齊方式

3. 模板系統(tǒng)

templates = {
    'simple': {'margin': 40, 'font_size': 12},
    'elegant': {'margin': 60, 'font_size': 14},
    'compact': {'margin': 20, 'font_size': 10}
}

4. 批量處理

  • 支持多個項目
  • 項目間快速切換
  • 批量導(dǎo)出

5. 云端同步

  • 項目保存到云端
  • 多設(shè)備協(xié)同編輯
  • 版本控制

常見問題與解決方案

問題1:中文字體不顯示

原因: 系統(tǒng)缺少中文字體或路徑錯誤

解決方案:

# 添加更多字體路徑
font_paths = [
    'simsun.ttc',                           # Windows
    '/System/Library/Fonts/STHeiti Light.ttc',  # macOS
    '/usr/share/fonts/truetype/wqy/wqy-microhei.ttc'  # Linux
]

for path in font_paths:
    try:
        pdfmetrics.registerFont(TTFont('SimSun', path))
        font_name = 'SimSun'
        break
    except:
        continue

問題2:圖片過大導(dǎo)致內(nèi)存溢出

解決方案: 在加載前預(yù)處理圖片

def optimize_image(image_path, max_size=(2000, 2000)):
    img = Image.open(image_path)
    img.thumbnail(max_size, Image.Resampling.LANCZOS)
    return img

問題3:PDF文件過大

解決方案: 壓縮圖片質(zhì)量

# 保存為JPEG并降低質(zhì)量
img.save(temp_path, 'JPEG', quality=85, optimize=True)
c.drawImage(temp_path, ...)

運行結(jié)果

pdf結(jié)果

以上就是基于Python開發(fā)一個小說圖片PDF生成器的詳細內(nèi)容,更多關(guān)于Python小說圖片PDF生成的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Python實現(xiàn)圖片拼接的代碼

    Python實現(xiàn)圖片拼接的代碼

    本文通過實例代碼給大家介紹了python實現(xiàn)圖片拼接的方法,非常不錯,具有一定的參考借鑒借鑒價值,需要的朋友參考下吧
    2018-07-07
  • Python坐標軸操作及設(shè)置代碼實例

    Python坐標軸操作及設(shè)置代碼實例

    這篇文章主要介紹了Python坐標軸操作及設(shè)置代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習或者工作具有一定的參考學(xué)習價值,需要的朋友可以參考下
    2020-06-06
  • 如何利用python實現(xiàn)Simhash算法

    如何利用python實現(xiàn)Simhash算法

    這篇文章主要介紹了如何利用python實現(xiàn)Simhash算法,文章基于python的相關(guān)資料展開Simhash算法的詳細介紹,具有一定的參考價值,感興趣的小伙伴可以參考一下
    2022-06-06
  • Python實現(xiàn)清理微信僵尸粉功能示例【基于itchat模塊】

    Python實現(xiàn)清理微信僵尸粉功能示例【基于itchat模塊】

    這篇文章主要介紹了Python實現(xiàn)清理微信僵尸粉功能,結(jié)合實例形式分析了Python使用itchat模塊刪除微信僵尸粉的相關(guān)原理、操作技巧與注意事項,需要的朋友可以參考下
    2020-05-05
  • Python Flask自定義URL路由參數(shù)過濾器的方法詳解

    Python Flask自定義URL路由參數(shù)過濾器的方法詳解

    Flask是一個輕量級的Python Web應(yīng)用框架,它允許開發(fā)者以一種簡潔明了的方式來構(gòu)建Web應(yīng)用,Flask自定義URL的主要功能在于使得開發(fā)者能夠通過簡單的路由規(guī)則來自定義應(yīng)用程序的URL結(jié)構(gòu),本文給大家介紹了Python Flask自定義URL路由參數(shù)過濾器的方法,需要的朋友可以參考下
    2024-07-07
  • Python中g(shù)lob庫實現(xiàn)文件名的匹配

    Python中g(shù)lob庫實現(xiàn)文件名的匹配

    本文主要主要介紹了Python中g(shù)lob庫實現(xiàn)文件名的匹配,對大家的學(xué)習或者工作具有一定的參考學(xué)習價值,需要的朋友們下面隨著小編來一起學(xué)習學(xué)習吧
    2021-06-06
  • Python random模塊用法解析及簡單示例

    Python random模塊用法解析及簡單示例

    這篇文章主要介紹了Python random模塊用法解析及簡單示例,具有一定借鑒價值,需要的朋友可以參考下。
    2017-12-12
  • 基于python實現(xiàn)圖書管理系統(tǒng)

    基于python實現(xiàn)圖書管理系統(tǒng)

    這篇文章主要為大家詳細介紹了基于python實現(xiàn)圖書管理系統(tǒng),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-04-04
  • python實現(xiàn)m3u8格式轉(zhuǎn)換為mp4視頻格式

    python實現(xiàn)m3u8格式轉(zhuǎn)換為mp4視頻格式

    這篇文章主要為大家詳細介紹了python實現(xiàn)m3u8格式轉(zhuǎn)換為mp4視頻格式,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-02-02
  • python 將字符串轉(zhuǎn)換成字典dict

    python 將字符串轉(zhuǎn)換成字典dict

    將字符串轉(zhuǎn)化成字典dict類型?這個可以用python的標準庫simplejson 轉(zhuǎn)換為JSON格式。
    2013-03-03

最新評論

陕西省| 新民市| 皋兰县| 大名县| 仙桃市| 柞水县| 郯城县| 体育| 凯里市| 原平市| 南汇区| 陆河县| 阿勒泰市| 宣城市| 合阳县| 特克斯县| 怀宁县| 贵定县| 田东县| 阿图什市| 兰溪市| 庐江县| 安乡县| 永定县| 鄂尔多斯市| 津南区| 华坪县| 舒兰市| 温州市| 贵德县| 正定县| 揭阳市| 泸州市| 齐齐哈尔市| 顺平县| 农安县| 南川市| 锦州市| 井陉县| 滨州市| 准格尔旗|