# Python 问题

URL: https://caijiao.org/how-to/python/
Source: docs/how-to/python/index.md
Description: Python 高频问题库，覆盖文件处理、JSON、CSV、PDF、requests、pandas、虚拟环境、SQLite 和自动化脚本。

这里集中处理 Python 日常脚本、数据处理、接口请求和工程环境中的高频问题。

## 文件与数据格式

- [Python 如何批量修改文件名](/how-to/python/batch-rename-files)
- [Python 如何读取和写入 JSON 文件](/how-to/python/read-write-json)
- [Python 如何合并 PDF 文件](/how-to/python/merge-pdf)
- [Python 如何拆分 PDF 文件](/how-to/python/split-pdf)
- [Python 如何把 CSV 转 JSON](/how-to/python/csv-to-json)
- [Python 如何把 JSON 转 CSV](/how-to/python/json-to-csv)
- [Python 如何读取 Excel 文件](/how-to/python/read-excel)
- [Python 如何写入 Excel 文件](/how-to/python/write-excel)
- [Python requests 如何发送 GET 请求](/how-to/python/requests-get)
- [Python requests 如何发送 JSON POST](/how-to/python/requests-post-json)
- [Python requests 如何设置超时](/how-to/python/requests-timeout)
- [Python 如何下载文件](/how-to/python/download-file)
- [Python requests 如何上传文件](/how-to/python/upload-file)
- [Python 如何解析 HTML](/how-to/python/parse-html)
- [Python 正则如何提取内容](/how-to/python/regex-extract)
- [Python 如何遍历目录文件](/how-to/python/pathlib-list-files)
- [Python 如何删除空文件](/how-to/python/delete-empty-files)
- [Python 如何复制文件和目录](/how-to/python/copy-files)
- [Python 如何压缩目录为 zip](/how-to/python/zip-directory)
- [Python 如何解压 zip 文件](/how-to/python/unzip-file)

## 请求、脚本与环境

- [Python 如何格式化日期时间](/how-to/python/datetime-format)
- [Python 时间戳如何转日期](/how-to/python/timestamp-convert)
- [Python 如何读取环境变量](/how-to/python/env-vars)
- [Python 如何写命令行参数](/how-to/python/argparse-cli)
- [Python 如何记录日志](/how-to/python/logging-basic)
- [Python try except 怎么写](/how-to/python/try-except)
- [Python 如何创建虚拟环境](/how-to/python/venv-create)
- [Python 如何导出依赖](/how-to/python/pip-freeze)
- [pip 安装很慢怎么办](/how-to/python/pip-timeout)
- [Python ModuleNotFoundError 怎么办](/how-to/python/module-not-found)
- [Python 相对导入报错怎么办](/how-to/python/relative-import-error)
- [Python 如何合并字典](/how-to/python/dict-merge)
- [Python 列表如何去重](/how-to/python/list-deduplicate)
- [Python 如何按字段分组列表](/how-to/python/group-list)
- [Python 如何按字典字段排序列表](/how-to/python/sort-list-dict)
- [Python f-string 如何格式化数字](/how-to/python/f-string-format)
- [Python 如何逐行读取大文件](/how-to/python/read-large-file)
- [Python 如何写入 UTF-8 文本](/how-to/python/write-text-utf8)
- [Python 如何执行系统命令](/how-to/python/subprocess-run)
- [Python 如何定时执行任务](/how-to/python/schedule-task)

## pandas、SQLite 与自动化

- [Python FastAPI 如何写一个接口](/how-to/python/fastapi-simple-api)
- [Python Flask 如何写一个接口](/how-to/python/flask-simple-api)
- [Python 如何查询 SQLite](/how-to/python/sqlite-query)
- [Python 如何插入 SQLite 数据](/how-to/python/sqlite-insert)
- [pandas 如何筛选数据](/how-to/python/pandas-filter)
- [pandas 如何按字段汇总](/how-to/python/pandas-groupby)
- [pandas 如何合并两个表](/how-to/python/pandas-merge)
- [Python 如何批量压缩图片](/how-to/python/image-resize)
- [Python 如何发送邮件](/how-to/python/send-email)
- [Python 如何生成 UUID](/how-to/python/uuid-generate)
- [Python 如何计算文件哈希](/how-to/python/hash-file)
- [Python 如何快速启动静态文件服务器](/how-to/python/http-server)
- [Python dataclass 怎么用](/how-to/python/dataclass)
- [Python 类型注解怎么写](/how-to/python/type-hints)
- [Python pytest 如何写测试](/how-to/python/pytest-basic)
- [Python 如何读取 TOML 配置](/how-to/python/config-toml)
- [Python 如何随机抽样](/how-to/python/random-sample)
- [Python 如何读取 YAML 配置](/how-to/python/read-yaml)
- [Python 如何用 Jinja2 渲染模板](/how-to/python/jinja2-render)
- [Python 执行命令如何设置超时](/how-to/python/subprocess-timeout)
