Files
Python-Learning-Resources/README.md
T
2026-04-10 10:56:50 +08:00

59 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Python-Learning-Resources
本项目用于整理和记录 Python 学习过程中的重要资料与工具文档,方便查阅与系统学习。
# 目录结构
Python-Learning-Resources/
├── [README.md](README.md) # 项目主说明文件
└── [psutil](psutil.md) # psutil 库详细功能文档
---
当前包含:
- [psutil 详细功能文档](psutil.md):跨平台系统监控库 `psutil` 的完整使用指南,涵盖 CPU、内存、磁盘、网络、进程管理等核心功能。
---
## psutil 快速概览
`psutil`(Python System and Process Utilities)是一个跨平台的 Python 库,用于检索系统运行时的信息,如 **CPU、内存、磁盘、网络、进程** 等。它支持 Linux、Windows、macOS、FreeBSD 等主流操作系统,是系统监控、性能分析和运维自动化的重要工具。
### 核心功能模块
- **CPU**:逻辑/物理核心数、使用率、时间统计
- **内存**:虚拟内存、交换内存使用情况
- **磁盘**:分区信息、使用情况、I/O 统计
- **网络**:I/O 统计、连接状态、接口信息
- **进程管理**:PID 获取、资源占用、线程与文件、进程控制
- **系统信息与传感器**:启动时间、用户、温度、电池状态
### 安装
```bash
pip install psutil
```
### 快速开始
```python
import psutil
print(psutil.cpu_percent(interval=1)) # 查看 CPU 使用率
mem = psutil.virtual_memory() # 查看内存信息
print(f"Total: {mem.total}, Available: {mem.available}, Used: {mem.percent}%")
print(psutil.disk_usage('/')) # 查看磁盘使用情况
print(psutil.pids()) # 查看所有进程 PID
```
详细用法请参考 [psutil.md](psutil.md)。
### 适用场景
- 系统资源实时监控
- 服务器性能分析
- 进程级资源审计
- 自动化运维脚本
- 安全/异常进程检测
---
> 更多 Python 学习资源将持续更新到此仓库。