欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用Python開發(fā)智能文件備份工具

 更新時間:2025年05月09日 08:25:55   作者:創(chuàng)客白澤  
在數字化時代,數據備份已成為個人和企業(yè)數據管理的重要環(huán)節(jié),本文將詳細介紹如何使用Python開發(fā)一款功能全面的桌面級文件備份工具,有需要的可以了解下

概述

在數字化時代,數據備份已成為個人和企業(yè)數據管理的重要環(huán)節(jié)。本文將詳細介紹如何使用Python開發(fā)一款功能全面的桌面級文件備份工具,該工具不僅支持即時備份,還能實現定時自動備份、增量備份等專業(yè)功能,并具備系統(tǒng)托盤駐留能力。通過tkinter+ttkbootstrap構建現代化UI界面,結合pystray實現后臺運行,是Python GUI開發(fā)的經典案例。

功能亮點

1.雙目錄選擇:可視化選擇源目錄和目標目錄

2.三種備份模式:

  • 立即執(zhí)行備份
  • 每日/每周定時備份
  • 精確到分鐘的自定義時間備份

3.增量備份機制:僅復制新增或修改過的文件

4.實時日志系統(tǒng):彩色分級日志輸出

5.進度可視化:帶條紋動畫的進度條

6.托盤駐留:最小化到系統(tǒng)托盤持續(xù)運行

7.異常處理:完善的錯誤捕獲和提示機制

技術架構

核心代碼解析

1. 增量備份實現

def execute_backup(self):
    for root, dirs, files in os.walk(self.source_path):
        rel_path = os.path.relpath(root, self.source_path)
        dest_path = os.path.join(self.dest_path, rel_path)
        os.makedirs(dest_path, exist_ok=True)
        
        for file in files:
            src_file = os.path.join(root, file)
            dest_file = os.path.join(dest_path, file)
            
            # 增量判斷邏輯
            if not os.path.exists(dest_file):
                need_copy = True  # 新文件
            else:
                src_mtime = os.path.getmtime(src_file)
                dest_mtime = os.path.getmtime(dest_file)
                need_copy = src_mtime > dest_mtime  # 修改時間比對

這段代碼實現了備份工具的核心功能——增量備份。通過對比源文件和目標文件的修改時間,僅當源文件較新時才執(zhí)行復制操作,大幅提升備份效率。

2. 定時任務調度

def calculate_next_run(self, hour, minute, weekday=None):
    now = datetime.now()
    if weekday is not None:  # 每周模式
        days_ahead = (weekday - now.weekday()) % 7
        next_date = now + timedelta(days=days_ahead)
        next_run = next_date.replace(hour=hour, minute=minute, second=0)
    else:  # 每日模式
        next_run = now.replace(hour=hour, minute=minute, second=0)
        if next_run < now:
            next_run += timedelta(days=1)
    return next_run

該算法實現了智能的下一次運行時間計算,支持按日和按周兩種循環(huán)模式,確保定時任務準確執(zhí)行。

3. 托盤圖標實現

def create_tray_icon(self):
    image = Image.new('RGBA', (64, 64), (255, 255, 255, 0))
    draw = ImageDraw.Draw(image)
    draw.ellipse((16, 16, 48, 48), fill=(33, 150, 243))
    
    menu = (
        pystray.MenuItem("打開主界面", self.restore_window),
        pystray.MenuItem("立即備份", self.start_backup_thread),
        pystray.Menu.SEPARATOR,
        pystray.MenuItem("退出", self.quit_app)
    )
    
    self.tray_icon = pystray.Icon("backup_tool", image, menu=menu)
    threading.Thread(target=self.tray_icon.run).start()

通過Pillow動態(tài)生成托盤圖標,結合pystray創(chuàng)建右鍵菜單,實現程序后臺持續(xù)運行能力。

使用教程

基礎備份操作

  • 點擊"選擇源目錄"按鈕指定需要備份的文件夾
  • 點擊"選擇目標目錄"按鈕設置備份存儲位置
  • 點擊"立即備份"按鈕開始執(zhí)行備份

定時備份設置

  • 選擇定時類型(每日/每周)
  • 設置具體執(zhí)行時間
    • 每日模式:只需設置時分
    • 每周模式:需額外選擇星期
  • 點擊"確認定時"按鈕保存設置

定時器邏輯層界面用戶定時器邏輯層界面用戶選擇定時類型更新UI選項設置具體時間點擊確認按鈕計算下次執(zhí)行時間顯示下次備份時間

進階功能解析

線程安全設計

def start_backup_thread(self):
    if self.validate_paths():
        threading.Thread(target=self.execute_backup, daemon=True).start()

采用多線程技術將耗時的備份操作放在后臺執(zhí)行,避免界面卡頓,同時設置為守護線程確保程序能正常退出。

日志系統(tǒng)實現

def log_message(self, message, level="INFO"):
    color_map = {
        "INFO": "#17a2b8", 
        "SUCCESS": "#28a745", 
        "WARNING": "#ffc107", 
        "ERROR": "#dc3545"
    }
    self.window.after(0, self._append_log, message, level, color_map.get(level))

通過after方法實現線程安全的日志更新,不同級別日志顯示不同顏色,方便問題排查。

完整源碼下載

import tkinter as tk
import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from tkinter import filedialog, messagebox, scrolledtext
import shutil
import os
import sys
from datetime import datetime, timedelta
import threading
from PIL import Image, ImageDraw
import pystray

class BackupApp:
    def __init__(self):
        self.window = ttk.Window(themename="litera")
        self.window.title("文件備份工具")
        self.window.geometry("465x700")
        self.window.resizable(False, False)
        self.window.minsize(465, 700)
        self.window.maxsize(465, 700)
        self.window.protocol("WM_DELETE_WINDOW", self.on_close)

        self.font = ("微軟雅黑", 10)
        self.source_path = ""
        self.dest_path = ""
        self.schedule_type = tk.StringVar(value='')
        self.scheduled_job = None
        self.current_schedule = {}

        main_frame = ttk.Frame(self.window, padding=20)
        main_frame.pack(fill=tk.BOTH, expand=True)

        dir_frame = ttk.Labelframe(main_frame, text="目錄設置", padding=15)
        dir_frame.pack(fill=tk.X, pady=10)

        dir_frame.grid_columnconfigure(0, weight=0)
        dir_frame.grid_columnconfigure(1, weight=1)
        dir_frame.grid_columnconfigure(2, weight=0)

        ttk.Button(
            dir_frame,
            text="選擇源目錄",
            command=self.select_source,
            bootstyle="primary-outline",
            width=15
        ).grid(row=0, column=0, padx=5, pady=5, sticky="w")
        self.source_label = ttk.Label(dir_frame, text="未選擇源目錄", bootstyle="info")
        self.source_label.grid(row=0, column=1, padx=5, sticky="w")

        ttk.Button(
            dir_frame,
            text="選擇目標目錄",
            command=self.select_destination,
            bootstyle="primary-outline",
            width=15
        ).grid(row=1, column=0, padx=5, pady=5, sticky="w")
        self.dest_label = ttk.Label(dir_frame, text="未選擇目標目錄", bootstyle="info")
        self.dest_label.grid(row=1, column=1, padx=5, sticky="w")

        ttk.Button(
            dir_frame,
            text="立即備份",
            command=self.start_backup_thread,
            bootstyle="success",
            width=15
        ).grid(row=0, column=2, rowspan=2, padx=15, sticky="ns")

        schedule_frame = ttk.Labelframe(main_frame, text="定時設置", padding=15)
        schedule_frame.pack(fill=tk.X, pady=10)

        type_frame = ttk.Frame(schedule_frame)
        type_frame.pack(fill=tk.X, pady=5)
        
        ttk.Radiobutton(
            type_frame,
            text="每日備份",
            variable=self.schedule_type,
            value='daily',
            bootstyle="info-toolbutton",
            command=self.update_schedule_ui
        ).pack(side=tk.LEFT, padx=5)
        
        ttk.Radiobutton(
            type_frame,
            text="每周備份",
            variable=self.schedule_type,
            value='weekly',
            bootstyle="info-toolbutton",
            command=self.update_schedule_ui
        ).pack(side=tk.LEFT)

        self.settings_container = ttk.Frame(schedule_frame)
        
        custom_frame = ttk.Labelframe(main_frame, text="自定義備份(精確到分鐘)", padding=15)
        custom_frame.pack(fill=tk.X, pady=10)

        custom_frame.grid_columnconfigure(0, weight=1)
        custom_frame.grid_columnconfigure(1, weight=0)
        custom_frame.grid_columnconfigure(2, weight=0)

        self.date_entry = ttk.DateEntry(
            custom_frame,
            bootstyle="primary",
            dateformat="%Y-%m-%d",
            startdate=datetime.now().date(),
            width=13
        )
        self.date_entry.grid(row=0, column=0, padx=5, sticky="w")

        time_selector = ttk.Frame(custom_frame)
        time_selector.grid(row=0, column=1, padx=(5,10), sticky="w")
        
        self.custom_hour = ttk.Combobox(
            time_selector,
            width=3,
            values=[f"{i:02d}" for i in range(24)],
            bootstyle="primary",
            state="readonly"
        )
        self.custom_hour.set("09")
        self.custom_hour.pack(side=tk.LEFT)
        
        ttk.Label(time_selector, text=":").pack(side=tk.LEFT)
        
        self.custom_minute = ttk.Combobox(
            time_selector,
            width=3,
            values=[f"{i:02d}" for i in range(60)],
            bootstyle="primary",
            state="readonly"
        )
        self.custom_minute.set("00")
        self.custom_minute.pack(side=tk.LEFT)

        ttk.Button(
            custom_frame,
            text="預定備份",
            command=self.custom_backup,
            bootstyle="success",
            width=10
        ).grid(row=0, column=2, padx=5, sticky="e")

        log_frame = ttk.Labelframe(main_frame, text="操作日志", padding=15)
        log_frame.pack(fill=tk.BOTH, expand=True, pady=10)
        
        self.log_area = scrolledtext.ScrolledText(
            log_frame,
            wrap=tk.WORD,
            font=("Consolas", 9),
            height=8,
            bg="#f8f9fa",
            fg="#495057"
        )
        self.log_area.pack(fill=tk.BOTH, expand=True)
        self.log_area.configure(state="disabled")

        self.status_label = ttk.Label(
            main_frame,
            text="就緒",
            bootstyle="inverse-default",
            font=("微軟雅黑", 9)
        )
        self.status_label.pack(fill=tk.X, pady=10)

        self.progress = ttk.Progressbar(
            main_frame,
            orient='horizontal',
            mode='determinate',
            bootstyle="success-striped",
            length=500
        )
        self.progress.pack(pady=10)

        self.window.bind("<Unmap>", self.check_minimized)
        self.create_tray_icon()

    def update_schedule_ui(self):
        for widget in self.settings_container.winfo_children():
            widget.destroy()
        
        time_frame = ttk.Frame(self.settings_container)
        time_frame.pack(side=tk.LEFT, fill=tk.X, expand=True)
        
        ttk.Label(time_frame, text="執(zhí)行時間:").pack(side=tk.LEFT)
        self.hour_var = ttk.Combobox(
            time_frame,
            width=3,
            values=[f"{i:02d}" for i in range(24)],
            bootstyle="primary",
            state="readonly"
        )
        self.hour_var.set("09")
        self.hour_var.pack(side=tk.LEFT, padx=5)
        
        ttk.Label(time_frame, text=":").pack(side=tk.LEFT)
        
        self.minute_var = ttk.Combobox(
            time_frame,
            width=3,
            values=[f"{i:02d}" for i in range(60)],
            bootstyle="primary",
            state="readonly"
        )
        self.minute_var.set("00")
        self.minute_var.pack(side=tk.LEFT)

        if self.schedule_type.get() == 'weekly':
            weekday_frame = ttk.Frame(self.settings_container)
            weekday_frame.pack(side=tk.LEFT, padx=20)
            
            self.weekday_selector = ttk.Combobox(
                weekday_frame,
                values=["星期一","星期二","星期三","星期四","星期五","星期六","星期日"],
                state="readonly",
                width=8,
                bootstyle="primary"
            )
            self.weekday_selector.pack()
            self.weekday_selector.set("星期一")

        ttk.Button(
            self.settings_container,
            text="確認定時",
            command=self.set_schedule,
            bootstyle="success",
            width=10
        ).pack(side=tk.RIGHT, padx=10)
        self.settings_container.pack(fill=tk.X, pady=10)

    def on_close(self):
        if messagebox.askokcancel("退出", "確定要退出程序嗎?"):
            self.quit_app()
        else:
            self.minimize_to_tray()

    def check_minimized(self, event):
        if self.window.state() == 'iconic':
            self.minimize_to_tray()

    def minimize_to_tray(self):
        self.window.withdraw()
        self.log_message("程序已最小化到托盤", "INFO")

    def restore_window(self, icon=None, item=None):
        self.window.deiconify()
        self.window.attributes('-topmost', 1)
        self.window.after(100, lambda: self.window.attributes('-topmost', 0))
        self.log_message("已恢復主窗口", "SUCCESS")

    def quit_app(self, icon=None, item=None):
        self.tray_icon.stop()
        self.window.destroy()
        sys.exit()

    def log_message(self, message, level="INFO"):
        color_map = {"INFO": "#17a2b8", "SUCCESS": "#28a745", "WARNING": "#ffc107", "ERROR": "#dc3545"}
        self.window.after(0, self._append_log, message, level, color_map.get(level, "#000000"))

    def _append_log(self, message, level, color):
        timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        formatted_msg = f"[{timestamp}] {level}: {message}\n"
        self.log_area.configure(state="normal")
        self.log_area.insert(tk.END, formatted_msg)
        self.log_area.tag_add(level, "end-2l linestart", "end-2l lineend")
        self.log_area.tag_config(level, foreground=color)
        self.log_area.see(tk.END)
        self.log_area.configure(state="disabled")

    def validate_paths(self):
        errors = []
        if not os.path.isdir(self.source_path):
            errors.append("源目錄無效或不存在")
        if not os.path.isdir(self.dest_path):
            errors.append("目標目錄無效或不存在")
        if errors:
            messagebox.showerror("路徑錯誤", "\n".join(errors))
            return False
        return True

    def start_backup_thread(self):
        if self.validate_paths():
            self.progress["value"] = 0
            threading.Thread(target=self.execute_backup, daemon=True).start()

    def execute_backup(self):
        try:
            self.log_message("開始備份準備...", "INFO")
            total_files = sum(len(files) for _, _, files in os.walk(self.source_path))
            self.log_message(f"發(fā)現待處理文件總數: {total_files}", "INFO")
            
            copied_files = 0
            processed_files = 0
            
            for root, dirs, files in os.walk(self.source_path):
                rel_path = os.path.relpath(root, self.source_path)
                self.log_message(f"正在處理目錄: {rel_path}", "INFO")
                
                dest_path = os.path.join(self.dest_path, rel_path)
                os.makedirs(dest_path, exist_ok=True)
                
                for file in files:
                    src_file = os.path.join(root, file)
                    dest_file = os.path.join(dest_path, file)
                    
                    need_copy = False
                    if not os.path.exists(dest_file):
                        need_copy = True
                        self.log_message(f"新增文件: {file}", "INFO")
                    else:
                        src_mtime = os.path.getmtime(src_file)
                        dest_mtime = os.path.getmtime(dest_file)
                        if src_mtime > dest_mtime:
                            need_copy = True
                            self.log_message(f"檢測到更新: {file}", "INFO")

                    if need_copy:
                        try:
                            shutil.copy2(src_file, dest_file)
                            copied_files += 1
                        except Exception as e:
                            self.log_message(f"文件 {file} 備份失敗: {str(e)}", "ERROR")
                    
                    processed_files += 1
                    self.progress["value"] = (processed_files / total_files) * 100
                    self.window.update()

            self.progress["value"] = 100
            self.window.after(0, self.show_completion_popup, copied_files)
            self.window.after(0, self.reschedule_backup)
            
        except Exception as e:
            self.log_message(f"備份失?。簕str(e)}", "ERROR")
            messagebox.showerror("備份失敗", str(e))
            self.progress["value"] = 0
        finally:
            self.window.update_idletasks()

    def show_completion_popup(self, copied_files):
        popup = tk.Toplevel(self.window)
        popup.title("備份完成")
        popup.geometry("300x150+%d+%d" % (
            self.window.winfo_x() + 100,
            self.window.winfo_y() + 100
        ))
        
        ttk.Label(popup, text=f"成功備份 {copied_files} 個文件", font=("微軟雅黑", 12)).pack(pady=20)
        popup.after(5000, popup.destroy)
        
        close_btn = ttk.Button(
            popup, 
            text="立即關閉", 
            command=popup.destroy,
            bootstyle="success-outline"
        )
        close_btn.pack(pady=10)

    def reschedule_backup(self):
        if self.current_schedule:
            try:
                next_run = self.calculate_next_run(
                    self.current_schedule['hour'],
                    self.current_schedule['minute'],
                    self.current_schedule.get('weekday')
                )
                delay = (next_run - datetime.now()).total_seconds()
                
                if delay > 0:
                    if self.scheduled_job:
                        self.window.after_cancel(self.scheduled_job)
                    
                    self.scheduled_job = self.window.after(
                        int(delay * 1000),
                        self.start_backup_thread
                    )
                    
                    self.status_label.configure(
                        text=f"下次備份時間: {next_run.strftime('%Y-%m-%d %H:%M')}",
                        bootstyle="inverse-info"
                    )
                    self.log_message(f"已更新下次備份時間: {next_run.strftime('%Y-%m-%d %H:%M')}", "SUCCESS")
                else:
                    self.log_message("無效的時間間隔,定時任務未設置", "ERROR")
            except Exception as e:
                self.log_message(f"重新安排定時失敗: {str(e)}", "ERROR")

    def set_schedule(self):
        try:
            if self.schedule_type.get() == 'weekly' and not hasattr(self, 'weekday_selector'):
                messagebox.showwarning("提示", "請選擇具體星期")
                return

            self.current_schedule = {
                'hour': int(self.hour_var.get()),
                'minute': int(self.minute_var.get()),
                'weekday': ["星期一","星期二","星期三","星期四","星期五","星期六","星期日"].index(
                    self.weekday_selector.get()) if self.schedule_type.get() == 'weekly' else None
            }

            self.reschedule_backup()

        except Exception as e:
            self.log_message(f"定時設置失?。簕str(e)}", "ERROR")
            messagebox.showerror("設置錯誤", str(e))

    def calculate_next_run(self, hour, minute, weekday=None):
        now = datetime.now()
        if weekday is not None:
            days_ahead = (weekday - now.weekday()) % 7
            next_date = now + timedelta(days=days_ahead)
            next_run = next_date.replace(hour=hour, minute=minute, second=0, microsecond=0)
            
            if next_run < now:
                next_run += timedelta(weeks=1)
        else:
            next_run = now.replace(hour=hour, minute=minute, second=0, microsecond=0)
            if next_run < now:
                next_run += timedelta(days=1)
        
        return next_run

    def custom_backup(self):
        try:
            selected_date = self.date_entry.entry.get()
            hour = int(self.custom_hour.get())
            minute = int(self.custom_minute.get())
            
            target_time = datetime.strptime(selected_date, "%Y-%m-%d").replace(
                hour=hour, minute=minute, second=0
            )
            
            if target_time < datetime.now():
                raise ValueError("時間不能早于當前時刻")
                
            delay = (target_time - datetime.now()).total_seconds()
            if delay <= 0:
                raise ValueError("定時時間必須晚于當前時間")
            
            self.window.after(int(delay * 1000), self.start_backup_thread)
            self.log_message(f"已預定備份時間:{target_time.strftime('%Y-%m-%d %H:%M')}", "SUCCESS")
            self.status_label.configure(
                text=f"預定備份時間: {target_time.strftime('%Y-%m-%d %H:%M')}",
                bootstyle="inverse-warning"
            )
            
        except Exception as e:
            self.log_message(f"預定失?。簕str(e)}", "ERROR")
            messagebox.showerror("設置錯誤", str(e))

    def create_tray_icon(self):
        try:
            image = Image.new('RGBA', (64, 64), (255, 255, 255, 0))
            draw = ImageDraw.Draw(image)
            draw.ellipse((16, 16, 48, 48), fill=(33, 150, 243))
            
            menu = (
                pystray.MenuItem("打開主界面", self.restore_window),
                pystray.MenuItem("立即備份", self.start_backup_thread),
                pystray.Menu.SEPARATOR,
                pystray.MenuItem("退出", self.quit_app)
            )
            
            self.tray_icon = pystray.Icon(
                "backup_tool",
                image,
                "數據備份工具",
                menu=menu
            )
            threading.Thread(target=self.tray_icon.run, daemon=True).start()
        except Exception as e:
            messagebox.showerror("托盤錯誤", f"初始化失敗: {str(e)}")
            sys.exit(1)

    def select_source(self):
        path = filedialog.askdirectory(title="選擇備份源文件夾")
        if path:
            self.source_path = path
            self.source_label.config(text=path)
            self.status_label.config(text="源目錄已更新", bootstyle="inverse-success")
            self.log_message(f"源目錄設置為: {path}", "INFO")

    def select_destination(self):
        path = filedialog.askdirectory(title="選擇備份存儲位置")
        if path:
            self.dest_path = path
            self.dest_label.config(text=path)
            self.status_label.config(text="目標目錄已更新", bootstyle="inverse-success")
            self.log_message(f"目標目錄設置為: {path}", "INFO")

if __name__ == "__main__":
    app = BackupApp()
    app.window.mainloop()

文件結構:

backup_tool/
├── main.py            # 主程序入口
├── requirements.txt   # 依賴庫清單
└── README.md          # 使用說明

安裝依賴:

pip install -r requirements.txt

總結與擴展

本文開發(fā)的備份工具具有以下技術亮點:

  • 采用現代化GUI框架ttkbootstrap,界面美觀
  • 完善的異常處理機制,健壯性強
  • 支持后臺運行,實用性強
  • 增量備份算法節(jié)省時間和存儲空間

擴展建議:

  • 增加云存儲支持(如阿里云OSS、七牛云等)
  • 添加壓縮備份功能
  • 實現多版本備份管理
  • 增加郵件通知功能

通過本項目的學習,讀者可以掌握:

  • Python GUI開發(fā)進階技巧
  • 定時任務調度實現
  • 系統(tǒng)托盤程序開發(fā)
  • 文件操作最佳實踐

相關技術棧

  • Python 3.8+
  • tkinter/ttkbootstrap
  • pystray
  • Pillow
  • shutil/os/sys

適用場景

  • 個人文檔備份
  • 開發(fā)項目版本存檔
  • 服務器重要文件備份
  • 自動化運維任務

以上就是使用Python開發(fā)智能文件備份工具的詳細內容,更多關于Python文件備份的資料請關注腳本之家其它相關文章!

相關文章

  • Python動態(tài)參數/命名空間/函數嵌套/global和nonlocal

    Python動態(tài)參數/命名空間/函數嵌套/global和nonlocal

    這篇文章主要介紹了Python動態(tài)參數/命名空間/函數嵌套/global和nonlocal,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值 ,需要的朋友可以參考下
    2019-05-05
  • Python中的GIL全局解釋器鎖多線程編程的隱患剖析

    Python中的GIL全局解釋器鎖多線程編程的隱患剖析

    Python作為一門強大而靈活的編程語言,吸引了大量的開發(fā)者,然而,對于多線程編程來說,Python引入了一個概念——全局解釋器鎖(Global Interpreter Lock,簡稱GIL),它在一定程度上影響了多線程程序的性能,本文將深入探討GIL的概念,它對多線程編程的影響以及如何處理與繞過它
    2023-10-10
  • python中matplotlib實現最小二乘法擬合的過程詳解

    python中matplotlib實現最小二乘法擬合的過程詳解

    這篇文章主要給大家介紹了關于python中matplotlib實現最小二乘法擬合的相關資料,文中通過示例代碼詳細介紹了關于最小二乘法擬合直線和最小二乘法擬合曲線的實現過程,需要的朋友可以參考借鑒,下面來一起看看吧。
    2017-07-07
  • 基于Python實現文件大小輸出

    基于Python實現文件大小輸出

    在數據庫中存儲時,使用 Bytes 更精確,可擴展性和靈活性都很高。下面通過本文給大家介紹基于Python實現文件大小輸出,對python文件輸出相關知識感興趣的朋友一起學習吧
    2016-01-01
  • Python 性能優(yōu)化技巧總結

    Python 性能優(yōu)化技巧總結

    代碼優(yōu)化能夠讓程序運行更快,它是在不改變程序運行結果的情況下使得程序的運行效率更高,根據 80/20 原則,實現程序的重構、優(yōu)化、擴展以及文檔相關的事情通常需要消耗 80% 的工作量。優(yōu)化通常包含兩方面的內容:減小代碼的體積,提高代碼的運行效率。
    2016-11-11
  • Python編程中的文件操作攻略

    Python編程中的文件操作攻略

    這篇文章主要介紹了Python編程中的文件操作攻略,包括打開關閉重命名刪除等相關函數的使用,需要的朋友可以參考下
    2015-10-10
  • Python使用Qt5實現水平導航欄的示例代碼

    Python使用Qt5實現水平導航欄的示例代碼

    本文主要介紹了Python使用Qt5實現水平導航欄的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-03-03
  • Python tkinter分隔控件(Seperator)的使用

    Python tkinter分隔控件(Seperator)的使用

    這篇文章主要介紹了Python tkinter分隔控件(Seperator)的使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-04-04
  • Python字符串的創(chuàng)建和駐留機制詳解

    Python字符串的創(chuàng)建和駐留機制詳解

    字符串駐留是一種在內存中僅保存一份相同且不可變字符串的方法,本文重點給大家介紹Python字符串的創(chuàng)建和駐留機制,感興趣的朋友跟隨小編一起看看吧
    2022-02-02
  • 6個Python辦公黑科技,助你提升工作效率

    6個Python辦公黑科技,助你提升工作效率

    這篇文章主要介紹了Python辦公黑科技,文中有非常詳細的代碼示例,對正在學習python的小伙伴們有非常好的幫助,需要的朋友可以參考下
    2021-08-08

最新評論