360 Secure SkillHub
360 安全技能中心

Python Automation

这是全栈Python自动化工具集,核心功能涵盖批量文件处理、多格式数据提取、Excel/PDF操作、网页爬取及重复系统任务自动化。提供常用库速查、代码示例及现成脚本,适用于批量整理文件、生成报表、爬取网页数据等场景,用户可通过代码或脚本完成任务,输出处理后的文件、数据结果。

ericlooi504
ericlooi504
热度 33.40
最近更新 2026-05-11 17:47:34
分类:开发依赖:代码执行 / 读写文件 / 联网浏览搜索 / 第三方 API应用场景:代码生成 / 自动化脚本 / 数据处理 / 文件转换 ...

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add python-automation
Metadata
name
python-automation
description
Full-stack Python automation toolkit for file processing, data extraction, PDF manipulation, Excel/workbook automation, web scraping, and system tasks. Use when the user needs to: (1) Process/rename/organize files in bulk, (2) Extract data from PDFs, CSVs, or web pages, (3) Generate or modify Excel reports, (4) Automate repetitive system tasks (cron, file watching), (5) Build quick CLI tools for data processing.

Python Automation

Core Libraries Quick Reference

Task Library Installation
File system pathlib, shutil, os stdlib
CSV csv stdlib
Excel openpyxl pip install openpyxl
Excel (old) xlrd / xlwt pip install xlrd xlwt
PDF text PyMuPDF (fitz) pip install PyMuPDF
PDF tables camelot-py / tabula-py pip install camelot-py
Web scraping requests + BeautifulSoup4 pip install requests beautifulsoup4
Browser automation playwright or selenium pip install playwright
CLI argparse (stdlib) or click stdlib / pip install click
Rich terminal rich pip install rich
File watching watchdog pip install watchdog
Scheduling schedule or cron pip install schedule

Common Patterns

1. Batch File Processing

from pathlib import Path

for f in Path(".").glob("**/*.txt"):
    content = f.read_text()
    # transform content
    f.write_text(content)

2. CSV Read/Write

import csv
with open("input.csv", newline="") as f:
    reader = csv.DictReader(f)
    for row in reader:
        print(row["column_name"])

with open("output.csv", "w", newline="") as f:
    writer = csv.writer(f)
    writer.writerow(["col1", "col2"])
    writer.writerow(["val1", "val2"])

3. Excel Generation

from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws["A1"] = "Hello"
ws["B1"] = 42
wb.save("output.xlsx")

4. Web Scraping

import requests
from bs4 import BeautifulSoup

resp = requests.get("https://example.com", timeout=10)
soup = BeautifulSoup(resp.text, "html.parser")
for link in soup.select("a[href]"):
    print(link["href"], link.text.strip())

Scripts

See scripts/ for ready-to-use automation scripts:

  • rename_batch.py — Batch rename files with pattern matching
  • csv_to_excel.py — Convert CSV files to Excel workbooks

Reference Files