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

Python實(shí)現(xiàn)安全清理各種系統(tǒng)垃圾文件

 更新時(shí)間:2025年12月04日 08:39:24   作者:零日失眠者  
本文將為大家詳細(xì)介紹一個(gè)實(shí)用的Python系統(tǒng)清理腳本工具,它可以安全地清理各種系統(tǒng)垃圾文件,幫助用戶釋放存儲(chǔ)空間并提升系統(tǒng)性能,有需要的小伙伴可以了解下

簡(jiǎn)介

隨著時(shí)間的推移,計(jì)算機(jī)會(huì)積累大量的臨時(shí)文件、緩存文件、日志文件和其他不必要的數(shù)據(jù),這些文件不僅占用寶貴的存儲(chǔ)空間,還可能影響系統(tǒng)的性能。定期清理這些無用文件是系統(tǒng)維護(hù)的重要環(huán)節(jié)。本文將介紹一個(gè)實(shí)用的Python腳本——系統(tǒng)清理工具,它可以安全地清理各種系統(tǒng)垃圾文件,幫助用戶釋放存儲(chǔ)空間并提升系統(tǒng)性能。

功能介紹

這個(gè)系統(tǒng)清理工具具有以下核心功能:

  • 多類型文件清理:支持清理臨時(shí)文件、緩存文件、日志文件、回收站等
  • 跨平臺(tái)支持:支持Windows、Linux和macOS操作系統(tǒng)
  • 安全清理機(jī)制:提供預(yù)覽模式,避免誤刪重要文件
  • 自定義清理規(guī)則:支持自定義要清理的文件類型和目錄
  • 磁盤空間統(tǒng)計(jì):顯示清理前后磁盤空間的變化
  • 日志記錄:記錄清理操作的詳細(xì)信息
  • 定時(shí)任務(wù)支持:可以集成到定時(shí)任務(wù)中定期清理系統(tǒng)
  • 白名單保護(hù):支持設(shè)置白名單,保護(hù)重要文件不被誤刪

應(yīng)用場(chǎng)景

這個(gè)工具適用于以下場(chǎng)景:

  • 日常系統(tǒng)維護(hù):定期清理系統(tǒng)垃圾文件
  • 存儲(chǔ)空間優(yōu)化:釋放磁盤空間,特別是存儲(chǔ)空間緊張時(shí)
  • 性能優(yōu)化:清理過多的臨時(shí)文件以提升系統(tǒng)性能
  • 系統(tǒng)準(zhǔn)備:在系統(tǒng)遷移或重裝前清理無用文件
  • 故障排查:清理可能引起問題的緩存文件
  • 隱私保護(hù):清理瀏覽歷史、臨時(shí)文件等隱私相關(guān)數(shù)據(jù)

報(bào)錯(cuò)處理

腳本包含了完善的錯(cuò)誤處理機(jī)制:

  • 權(quán)限驗(yàn)證:檢查是否有足夠的權(quán)限訪問和刪除文件
  • 路徑安全性檢查:驗(yàn)證要清理的路徑是否安全,防止誤刪系統(tǒng)關(guān)鍵文件
  • 文件鎖定處理:處理被其他程序占用的文件
  • 磁盤空間檢查:在操作前檢查是否有足夠的磁盤空間
  • 異常捕獲:捕獲并處理運(yùn)行過程中可能出現(xiàn)的各種異常
  • 回滾機(jī)制:在必要時(shí)提供操作回滾功能

代碼實(shí)現(xiàn)

import os
import sys
import argparse
import json
import shutil
import tempfile
from datetime import datetime, timedelta
import platform
import glob

class SystemCleaner:
    def __init__(self):
        self.os_type = platform.system().lower()
        self.cleanup_rules = []
        self.whitelist = set()
        self.cleaned_files = []
        self.cleaned_size = 0
        self.errors = []
        
        # 默認(rèn)清理規(guī)則
        self._set_default_rules()
        
    def _set_default_rules(self):
        """設(shè)置默認(rèn)清理規(guī)則"""
        if self.os_type == 'windows':
            # Windows系統(tǒng)默認(rèn)清理規(guī)則
            self.cleanup_rules.extend([
                {
                    'name': '臨時(shí)文件',
                    'paths': [
                        os.environ.get('TEMP', ''),
                        os.path.join(os.environ.get('SYSTEMROOT', ''), 'Temp'),
                        os.path.expanduser('~\\AppData\\Local\\Temp')
                    ],
                    'patterns': ['*'],
                    'age_days': 7
                },
                {
                    'name': '回收站',
                    'paths': [os.path.join(drive + ':\\', '$Recycle.Bin') for drive in 'CDEFGHIJKLMNOPQRSTUVWXYZ'],
                    'patterns': ['*'],
                    'age_days': 30
                },
                {
                    'name': '瀏覽器緩存',
                    'paths': [
                        os.path.expanduser('~\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cache'),
                        os.path.expanduser('~\\AppData\\Local\\Mozilla\\Firefox\\Profiles\\*\\cache2'),
                        os.path.expanduser('~\\AppData\\Local\\Microsoft\\Edge\\User Data\\Default\\Cache')
                    ],
                    'patterns': ['*'],
                    'age_days': 7
                }
            ])
        elif self.os_type == 'linux':
            # Linux系統(tǒng)默認(rèn)清理規(guī)則
            self.cleanup_rules.extend([
                {
                    'name': '臨時(shí)文件',
                    'paths': ['/tmp', '/var/tmp'],
                    'patterns': ['*'],
                    'age_days': 7
                },
                {
                    'name': '用戶緩存',
                    'paths': [os.path.expanduser('~/.cache')],
                    'patterns': ['*'],
                    'age_days': 30
                },
                {
                    'name': '日志文件',
                    'paths': ['/var/log'],
                    'patterns': ['*.log.*', '*.gz'],
                    'age_days': 30
                }
            ])
        elif self.os_type == 'darwin':  # macOS
            # macOS系統(tǒng)默認(rèn)清理規(guī)則
            self.cleanup_rules.extend([
                {
                    'name': '臨時(shí)文件',
                    'paths': ['/tmp', '/var/tmp'],
                    'patterns': ['*'],
                    'age_days': 7
                },
                {
                    'name': '用戶緩存',
                    'paths': [os.path.expanduser('~/Library/Caches')],
                    'patterns': ['*'],
                    'age_days': 30
                },
                {
                    'name': '日志文件',
                    'paths': [os.path.expanduser('~/Library/Logs')],
                    'patterns': ['*.log.*'],
                    'age_days': 30
                }
            ])
            
    def add_whitelist(self, paths):
        """添加白名單路徑"""
        if isinstance(paths, str):
            paths = [paths]
        for path in paths:
            self.whitelist.add(os.path.abspath(path))
            
    def load_config(self, config_file):
        """從配置文件加載清理規(guī)則"""
        try:
            with open(config_file, 'r', encoding='utf-8') as f:
                config = json.load(f)
                
            # 加載清理規(guī)則
            if 'cleanup_rules' in config:
                self.cleanup_rules = config['cleanup_rules']
                
            # 加載白名單
            if 'whitelist' in config:
                self.add_whitelist(config['whitelist'])
                
            return True
        except Exception as e:
            self.errors.append(f"加載配置文件失敗: {e}")
            return False
            
    def save_config(self, config_file):
        """保存配置到文件"""
        try:
            config = {
                'cleanup_rules': self.cleanup_rules,
                'whitelist': list(self.whitelist)
            }
            
            with open(config_file, 'w', encoding='utf-8') as f:
                json.dump(config, f, indent=2, ensure_ascii=False)
                
            return True
        except Exception as e:
            self.errors.append(f"保存配置文件失敗: {e}")
            return False
            
    def format_bytes(self, bytes_value):
        """格式化字節(jié)單位"""
        for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
            if bytes_value < 1024.0:
                return f"{bytes_value:.2f} {unit}"
            bytes_value /= 1024.0
        return f"{bytes_value:.2f} PB"
        
    def is_safe_path(self, path):
        """檢查路徑是否安全"""
        # 檢查是否在白名單中
        abs_path = os.path.abspath(path)
        for whitelist_path in self.whitelist:
            if abs_path.startswith(whitelist_path):
                return False
                
        # 檢查是否是系統(tǒng)關(guān)鍵目錄
        critical_paths = []
        if self.os_type == 'windows':
            system_root = os.environ.get('SYSTEMROOT', 'C:\\Windows')
            critical_paths = [system_root, 'C:\\Program Files', 'C:\\Program Files (x86)']
        elif self.os_type in ['linux', 'darwin']:
            critical_paths = ['/bin', '/sbin', '/usr/bin', '/usr/sbin', '/etc', '/boot']
            
        for critical_path in critical_paths:
            if abs_path.startswith(critical_path):
                return False
                
        return True
        
    def get_file_age(self, filepath):
        """獲取文件年齡(天數(shù))"""
        try:
            file_time = os.path.getmtime(filepath)
            file_datetime = datetime.fromtimestamp(file_time)
            age = datetime.now() - file_datetime
            return age.days
        except:
            return 0
            
    def match_patterns(self, filename, patterns):
        """檢查文件名是否匹配模式"""
        for pattern in patterns:
            if glob.fnmatch.fnmatch(filename, pattern):
                return True
        return False
        
    def scan_files(self, rule):
        """掃描符合規(guī)則的文件"""
        found_files = []
        
        for path in rule['paths']:
            if not path or not os.path.exists(path):
                continue
                
            try:
                # 遞歸遍歷目錄
                for root, dirs, files in os.walk(path):
                    # 跳過隱藏目錄
                    dirs[:] = [d for d in dirs if not d.startswith('.')]
                    
                    for filename in files:
                        # 跳過隱藏文件
                        if filename.startswith('.'):
                            continue
                            
                        filepath = os.path.join(root, filename)
                        
                        # 檢查文件是否匹配模式
                        if not self.match_patterns(filename, rule['patterns']):
                            continue
                            
                        # 檢查文件年齡
                        if 'age_days' in rule:
                            file_age = self.get_file_age(filepath)
                            if file_age < rule['age_days']:
                                continue
                                
                        # 檢查路徑安全性
                        if not self.is_safe_path(filepath):
                            continue
                            
                        # 獲取文件大小
                        try:
                            file_size = os.path.getsize(filepath)
                        except:
                            file_size = 0
                            
                        found_files.append({
                            'path': filepath,
                            'size': file_size,
                            'age': self.get_file_age(filepath)
                        })
                        
            except Exception as e:
                self.errors.append(f"掃描目錄 {path} 時(shí)出錯(cuò): {e}")
                
        return found_files
        
    def preview_cleanup(self):
        """預(yù)覽清理操作"""
        print("系統(tǒng)清理預(yù)覽")
        print("=" * 60)
        print(f"操作系統(tǒng): {self.os_type}")
        print()
        
        total_files = 0
        total_size = 0
        
        for rule in self.cleanup_rules:
            print(f"清理規(guī)則: {rule['name']}")
            files = self.scan_files(rule)
            
            if files:
                rule_size = sum(f['size'] for f in files)
                print(f"  發(fā)現(xiàn)文件: {len(files)} 個(gè)")
                print(f"  預(yù)計(jì)釋放: {self.format_bytes(rule_size)}")
                total_files += len(files)
                total_size += rule_size
                
                # 顯示前10個(gè)文件作為示例
                print("  文件示例:")
                for i, file_info in enumerate(files[:10]):
                    print(f"    {file_info['path']} ({self.format_bytes(file_info['size'])}, {file_info['age']}天)")
                if len(files) > 10:
                    print(f"    ... 還有 {len(files) - 10} 個(gè)文件")
            else:
                print("  未發(fā)現(xiàn)符合條件的文件")
            print()
            
        print(f"總計(jì):")
        print(f"  文件數(shù)量: {total_files}")
        print(f"  預(yù)計(jì)釋放: {self.format_bytes(total_size)}")
        
        return total_files, total_size
        
    def perform_cleanup(self, dry_run=True):
        """執(zhí)行清理操作"""
        print(f"{'預(yù)覽' if dry_run else '執(zhí)行'}系統(tǒng)清理")
        print("=" * 60)
        
        self.cleaned_files = []
        self.cleaned_size = 0
        cleaned_count = 0
        
        for rule in self.cleanup_rules:
            print(f"處理規(guī)則: {rule['name']}")
            files = self.scan_files(rule)
            
            for file_info in files:
                filepath = file_info['path']
                filesize = file_info['size']
                
                if dry_run:
                    print(f"  將刪除: {filepath} ({self.format_bytes(filesize)})")
                else:
                    try:
                        os.remove(filepath)
                        print(f"  已刪除: {filepath}")
                        self.cleaned_files.append(filepath)
                        self.cleaned_size += filesize
                        cleaned_count += 1
                    except Exception as e:
                        error_msg = f"刪除文件 {filepath} 失敗: {e}"
                        print(f"  錯(cuò)誤: {error_msg}")
                        self.errors.append(error_msg)
                        
            print()
            
        if not dry_run:
            print(f"清理完成:")
            print(f"  刪除文件: {cleaned_count} 個(gè)")
            print(f"  釋放空間: {self.format_bytes(self.cleaned_size)}")
            
        return cleaned_count, self.cleaned_size
        
    def clean_empty_dirs(self, dry_run=True):
        """清理空目錄"""
        print(f"{'預(yù)覽' if dry_run else '執(zhí)行'}空目錄清理")
        print("=" * 60)
        
        cleaned_dirs = 0
        
        for rule in self.cleanup_rules:
            for path in rule['paths']:
                if not path or not os.path.exists(path):
                    continue
                    
                try:
                    for root, dirs, files in os.walk(path, topdown=False):
                        # 檢查目錄是否為空
                        if not os.listdir(root):
                            if dry_run:
                                print(f"  將刪除空目錄: {root}")
                            else:
                                try:
                                    os.rmdir(root)
                                    print(f"  已刪除空目錄: {root}")
                                    cleaned_dirs += 1
                                except Exception as e:
                                    error_msg = f"刪除目錄 {root} 失敗: {e}"
                                    print(f"  錯(cuò)誤: {error_msg}")
                                    self.errors.append(error_msg)
                except Exception as e:
                    self.errors.append(f"遍歷目錄 {path} 時(shí)出錯(cuò): {e}")
                    
        if not dry_run:
            print(f"空目錄清理完成: {cleaned_dirs} 個(gè)目錄")
            
        return cleaned_dirs
        
    def generate_report(self):
        """生成清理報(bào)告"""
        report = []
        report.append("=" * 80)
        report.append("系統(tǒng)清理報(bào)告")
        report.append("=" * 80)
        report.append(f"清理時(shí)間: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
        report.append(f"操作系統(tǒng): {self.os_type}")
        report.append("")
        
        # 清理統(tǒng)計(jì)
        report.append("清理統(tǒng)計(jì):")
        report.append(f"  刪除文件: {len(self.cleaned_files)} 個(gè)")
        report.append(f"  釋放空間: {self.format_bytes(self.cleaned_size)}")
        report.append("")
        
        # 清理的文件列表
        if self.cleaned_files:
            report.append("已清理的文件:")
            report.append("-" * 50)
            for filepath in self.cleaned_files:
                report.append(f"  {filepath}")
            report.append("")
            
        # 錯(cuò)誤信息
        if self.errors:
            report.append("錯(cuò)誤信息:")
            report.append("-" * 50)
            for error in self.errors[:20]:  # 只顯示前20個(gè)錯(cuò)誤
                report.append(f"  {error}")
            if len(self.errors) > 20:
                report.append(f"  ... 還有 {len(self.errors) - 20} 個(gè)錯(cuò)誤")
            report.append("")
            
        report.append("=" * 80)
        return "\n".join(report)
        
    def save_report(self, filename):
        """保存報(bào)告到文件"""
        try:
            report = self.generate_report()
            with open(filename, 'w', encoding='utf-8') as f:
                f.write(report)
            print(f"報(bào)告已保存到: {filename}")
            return True
        except Exception as e:
            print(f"保存報(bào)告時(shí)出錯(cuò): {e}")
            return False

def create_sample_config():
    """創(chuàng)建示例配置文件"""
    config = {
        "cleanup_rules": [
            {
                "name": "自定義臨時(shí)文件",
                "paths": ["/custom/temp/path"],
                "patterns": ["*.tmp", "*.temp"],
                "age_days": 7
            }
        ],
        "whitelist": [
            "/important/files/not/to/delete"
        ]
    }
    
    try:
        with open('cleaner_config.json', 'w', encoding='utf-8') as f:
            json.dump(config, f, indent=2, ensure_ascii=False)
        print("示例配置文件已創(chuàng)建: cleaner_config.json")
        return True
    except Exception as e:
        print(f"創(chuàng)建示例配置文件時(shí)出錯(cuò): {e}")
        return False

def main():
    parser = argparse.ArgumentParser(description="系統(tǒng)清理工具")
    parser.add_argument("-c", "--config", help="配置文件路徑")
    parser.add_argument("-p", "--preview", action="store_true", help="預(yù)覽模式,不實(shí)際刪除文件")
    parser.add_argument("-o", "--output", help="保存報(bào)告到文件")
    parser.add_argument("--create-config", action="store_true", help="創(chuàng)建示例配置文件")
    parser.add_argument("--clean-empty-dirs", action="store_true", help="清理空目錄")
    parser.add_argument("--add-whitelist", action="append", help="添加白名單路徑")
    
    args = parser.parse_args()
    
    # 創(chuàng)建示例配置文件
    if args.create_config:
        create_sample_config()
        return
        
    try:
        cleaner = SystemCleaner()
        
        # 加載配置文件
        if args.config:
            if not cleaner.load_config(args.config):
                print("加載配置文件失敗")
                sys.exit(1)
                
        # 添加白名單
        if args.add_whitelist:
            cleaner.add_whitelist(args.add_whitelist)
            
        # 預(yù)覽或執(zhí)行清理
        if args.preview:
            cleaner.preview_cleanup()
        else:
            # 執(zhí)行清理
            cleaned_count, cleaned_size = cleaner.perform_cleanup(dry_run=False)
            
            # 清理空目錄
            if args.clean_empty_dirs:
                cleaner.clean_empty_dirs(dry_run=False)
                
            # 生成報(bào)告
            if args.output:
                cleaner.save_report(args.output)
            else:
                print(cleaner.generate_report())
                
    except KeyboardInterrupt:
        print("\n\n用戶中斷操作")
    except Exception as e:
        print(f"程序執(zhí)行出錯(cuò): {e}")
        sys.exit(1)

if __name__ == "__main__":
    main()

使用方法

基本使用

# 創(chuàng)建示例配置文件
python system_cleaner.py --create-config

# 預(yù)覽清理操作(不實(shí)際刪除文件)
python system_cleaner.py --preview

# 執(zhí)行清理操作
python system_cleaner.py

# 使用配置文件
python system_cleaner.py -c cleaner_config.json

# 保存清理報(bào)告
python system_cleaner.py -o cleanup_report.txt

# 清理空目錄
python system_cleaner.py --clean-empty-dirs

# 添加白名單路徑
python system_cleaner.py --add-whitelist /important/data --preview

配置文件示例

創(chuàng)建的示例配置文件 cleaner_config.json 內(nèi)容如下:

{
  "cleanup_rules": [
    {
      "name": "自定義臨時(shí)文件",
      "paths": ["/custom/temp/path"],
      "patterns": ["*.tmp", "*.temp"],
      "age_days": 7
    }
  ],
  "whitelist": [
    "/important/files/not/to/delete"
  ]
}

命令行參數(shù)說明

  • -c, --config: 配置文件路徑
  • -p, --preview: 預(yù)覽模式,不實(shí)際刪除文件
  • -o, --output: 保存報(bào)告到指定文件
  • --create-config: 創(chuàng)建示例配置文件
  • --clean-empty-dirs: 清理空目錄
  • --add-whitelist: 添加白名單路徑(可多次使用)

使用示例

預(yù)覽清理操作

python system_cleaner.py --preview

執(zhí)行清理并保存報(bào)告

python system_cleaner.py -o cleanup_$(date +%Y%m%d).txt

使用自定義配置

python system_cleaner.py -c my_cleaner_config.json --preview

添加白名單并清理

python system_cleaner.py --add-whitelist /home/user/important --clean-empty-dirs

總結(jié)

這個(gè)系統(tǒng)清理工具提供了一個(gè)安全、靈活的系統(tǒng)清理解決方案,能夠跨平臺(tái)清理各種類型的垃圾文件。它具有預(yù)覽模式、白名單保護(hù)、自定義規(guī)則等安全特性,可以有效防止誤刪重要文件。工具支持配置文件管理,便于定制清理規(guī)則,適用于日常系統(tǒng)維護(hù)、存儲(chǔ)空間優(yōu)化和性能提升等多種場(chǎng)景。通過定期使用這個(gè)工具,用戶可以保持系統(tǒng)的清潔和高效運(yùn)行。

以上就是Python實(shí)現(xiàn)安全清理各種系統(tǒng)垃圾文件的詳細(xì)內(nèi)容,更多關(guān)于Python清理系統(tǒng)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 基于python實(shí)現(xiàn)matlab filter函數(shù)過程詳解

    基于python實(shí)現(xiàn)matlab filter函數(shù)過程詳解

    這篇文章主要介紹了基于python實(shí)現(xiàn)matlab filter函數(shù)過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-06-06
  • Python爬蟲eval實(shí)現(xiàn)看漫畫漫畫柜mhgui實(shí)戰(zhàn)分析

    Python爬蟲eval實(shí)現(xiàn)看漫畫漫畫柜mhgui實(shí)戰(zhàn)分析

    這篇文章主要為大家介紹了Python爬蟲eval實(shí)現(xiàn)看漫畫漫畫柜mhgui實(shí)戰(zhàn)分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • Django 重寫用戶模型的實(shí)現(xiàn)

    Django 重寫用戶模型的實(shí)現(xiàn)

    這篇文章主要介紹了Django 重寫用戶模型的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07
  • Python之變量命名規(guī)則詳解

    Python之變量命名規(guī)則詳解

    Python變量命名需遵守語法規(guī)范(字母開頭、不使用關(guān)鍵字),遵循三要(自解釋、明確功能)和三不要(避免縮寫、語法錯(cuò)誤、濫用下劃線)原則,確保代碼易讀易維護(hù)
    2025-09-09
  • Python切割大日志文件幾種方法

    Python切割大日志文件幾種方法

    文本文介紹了如何通過三種方式處理過大日志文件,包括按文件數(shù)量、按文件大小和按行數(shù)分割,以方便排查問題,感興趣的可以了解一下
    2025-12-12
  • python中sort sorted reverse reversed函數(shù)的區(qū)別說明

    python中sort sorted reverse reversed函數(shù)的區(qū)別說明

    這篇文章主要介紹了python中sort sorted reverse reversed函數(shù)的區(qū)別說明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-05-05
  • 解決python 自動(dòng)安裝缺少模塊的問題

    解決python 自動(dòng)安裝缺少模塊的問題

    今天小編就為大家分享一篇解決python 自動(dòng)安裝缺少模塊的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-10-10
  • Python configparser模塊操作代碼實(shí)例

    Python configparser模塊操作代碼實(shí)例

    這篇文章主要介紹了Python configparser模塊操作代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-06-06
  • 使用wxPython實(shí)現(xiàn)逐行加載HTML內(nèi)容并實(shí)時(shí)顯示效果

    使用wxPython實(shí)現(xiàn)逐行加載HTML內(nèi)容并實(shí)時(shí)顯示效果

    這篇博客中,我們將詳細(xì)分析如何使用 wxPython 構(gòu)建一個(gè)簡(jiǎn)單的桌面應(yīng)用程序,用于逐行加載并顯示 HTML 文件的內(nèi)容,并在加載完成后通過瀏覽器組件呈現(xiàn)最終頁面,通過該應(yīng)用,我們可以體驗(yàn)到逐行加載 HTML 內(nèi)容的視覺效果,類似于模擬代碼輸入,需要的朋友可以參考下
    2024-11-11
  • python寫入csv時(shí)writerow()和writerows()函數(shù)簡(jiǎn)單示例

    python寫入csv時(shí)writerow()和writerows()函數(shù)簡(jiǎn)單示例

    這篇文章主要給大家介紹了關(guān)于python寫入csv時(shí)writerow()和writerows()函數(shù)的相關(guān)資料,writerows和writerow是Python中csv模塊中的兩個(gè)函數(shù),用于將數(shù)據(jù)寫入CSV文件,需要的朋友可以參考下
    2023-07-07

最新評(píng)論

汝州市| 莒南县| 太仓市| 抚宁县| 娱乐| 遂昌县| 河北区| 剑川县| 定陶县| 祁连县| 乳源| 鲁山县| 贵南县| 淮阳县| 西乌| 萝北县| 博兴县| 上栗县| 绵竹市| 大方县| 平江县| 新野县| 吉水县| 德化县| 凌源市| 两当县| 台北县| 拉萨市| 西平县| 平乡县| 莲花县| 花莲市| 兴国县| 读书| 靖西县| 朔州市| 林周县| 永吉县| 榆林市| 汉沽区| 正阳县|