Python 是一种高级、解释型、通用编程语言,专为可读性和生产力而设计。它的理念强调清晰、简洁的代码——"应该有一种显而易见的方法来做这件事。"
主要特性
python
():
name:
✓ Interpreted — runs line by line, no separate compile step (fast to iterate)
✓ Dynamically typed — variables don't declare types; checked at runtime
✓ Strongly typed — no implicit weird coercions ("1" + 1 raises an error)
✓ Readable — indentation-based, minimal punctuation, English-like
✓ Multi-paradigm — procedural, object-oriented, and functional styles
✓ "Batteries included" — a large standard library
✓ Huge ecosystem — PyPI packages for nearly everything
x = 5 # x is an int
x = "hello" # now x is a str — types are bound to VALUES, not variables
"1" + 1 # ❌ TypeError — strong typing won't silently coerce (unlike JS)
变量是无类型的(动态),但 Python 不会悄悄地混合不兼容的类型(强) —— 这是灵活性和安全性的平衡。
✓ Web back-ends (Django, FastAPI, Flask)
✓ Data science / ML / AI (NumPy, pandas, PyTorch, TensorFlow) — the dominant language
✓ Automation, scripting, DevOps tooling
✓ Data engineering, scientific computing
Python is SLOWER than compiled languages (interpreted, dynamic) and the GIL limits
CPU parallelism — but its readability, speed of development, and ecosystem usually
outweigh raw runtime speed for most tasks (and hot paths use C-backed libraries).
Python 结合了可读性、生产力和庞大的生态系统,使其成为最受欢迎的编程语言之一 —— 在数据科学/AI/ML 领域占据主导地位,也是 Web 后端、自动化和脚本编写的首选。
理解其核心特性(解释型、动态和强类型、注重可读性、多范式)及其权衡(开发者速度优先于原始执行速度)说明了为什么它被选用于这么多领域,以及它与编译型或弱类型语言的区别。