跳到导航 跳到搜索
Sculpture by Pietro Francavilla of Apollo's first triumph, when he slew with his bow and arrows the serpent Python, which lies dead at his feet. The Walters Art Museum.

Python is a programming language that lets you work quickly and integrate systems more effectively.

Whether you're new to programming or an experienced developer, it's easy to learn and use Python.

Python is powerful... and fast;

plays well with others;

runs everywhere;

is friendly & easy to learn;

is Open.

There should be one -- and preferably only one -- obvious way to do it.

In Greek Mythology, Python was the serpent, sometimes represented as a dragon, living at the centre of the earth, believed by the ancient Greeks to be at Delphi.


  • Imposed a Unicode model with broad consequences for strings, files, and libraries
  • Elevated iterators and generators to a more pervasive role, as part of fuller functional paradigm
  • Mandated new-style classes, which merge with types, but grow more powerful and complex
  • Changed many fundamental tools and libraries, and replaced or removed others entirely


Install Python 3.6 for macOS[1]:

tar -xvf Python-3.6.4.tar
cd Python-3.6.4
sudo make install
/usr/bin/ruby -e "$(curl -fsSL"
brew install zlib
sudo make install
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0


ipython notebook

The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, machine learning and much more.

The Notebook has support for over 40 programming languages, including those popular in Data Science such as Python, R, Julia and Scala.


配合 Cmder 使用,完美。

Anaconda Distribution is a free, easy-to-install package manager, environment manager and Python distribution with a collection of over 720 open source packages with free community support.

Anaconda is platform-agnostic, so you can use it whether you are on Windows, macOS or Linux.


>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!



#!/usr/bin/env python
# -*- coding: utf-8 -*-
python -m SimpleHTTPServer 8000

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
python -m http.server


Defining the Encoding



Introduction to Python


Intrigued by Python? Learn how to get started with this popular language, whether you’re new to programming or just new to Python. This engaging video course teaches you Python’s core concepts and data types through hands-on exercises, and delivers fun and useful projects so you can put everything together.

With an emphasis on code readability, Python enables programmers to express concepts in fewer lines of code than you can with many other languages. Open source developer Jessica McKellar helps you discover what’s possible with Python and provides the foundation you need to begin writing programs of your own.

  • Set up a development environment with Python and a text editor
  • Explore basic data types such as integers, strings, lists, and dictionaries
  • Learn how looping lets you do lots of work with a little bit of code
  • Gain access to more functionality in Python with modules
  • Practice reading, writing, and running your first Python programs
  • Navigate the command line for writing larger programs
  • Write your own functions for encapsulating useful work
  • Use classes to group, name, and reuse functions and variables
  • Practice what you’ve learned with the state capitals quizzer and Scrabble cheater projects

By Jessica McKellar

Table of Contents

  1. What Can You Do With Python
  2. Environment Setup
  3. Python Basic Data Types
  4. Making Choices- booleans, if-elif-else, compound conditionals
  5. Lists: list, tuple, range enumerate
  6. Loops
  7. Dictionaries: dict
  8. Modules: random
  9. Command Line Navigation
  10. Python Scripts and Files
  11. State Capitals Quizzer
  12. While Loop if for while with
  13. Reading From and Writing To Files files
  14. Files Practice- Flashcard Quizzer
  15. Functions
  16. Functions Practice - Wordplay
  17. Classes
  18. Scrabble Cheater
  19. Course Closing

Let's Dive into

Learning the Python 3 Standard Library

To do

网易的两大游戏客户端引擎,NeoX 和 Messiah,都是使用 Python 作为脚本语言的。具体来说,服务器端可以说是完全Python,毕竟能够热更新的Python可以不停服!当然游戏的客户端核心引擎部分,还是用C++,一些类似基本渲染还是用C++来实现的。


Python做人工智能的好处:简单高效、优质的文档、强大的AI库、海量的模块,成为研究AI最常用的开发语言。由于Explosion AI是基于Python的NLP库spaCy的制作者,所以调查中Python开发者占多数。










除了网络和互联网的支持,Python还提供了对底层网络的支持,有易于使用的Socket接口和一个异步的网络编程框架Twisted Python。


  1. 使用 sudo 命令,管理员用户密码不能为空。但是安装并不顺利,提示缺少 zlib。通过 HomeBrew 安装 zlib,Xcode Command Line Tool 版本过低,需要升级到 7.2。