Python

来自夜航船
跳转至: 导航搜索
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.

https://www.python.org/

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.

Python 3

  • 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

Jupyter

http://jupyter.org/

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.

Anaconda

https://www.continuum.io/

配合 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.

Zen

>>> 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!

Tutorials

Online

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

Encoding:

Defining the Encoding

Books

Videos

Introduction to Python

Jessica

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 dicision making
  5. Lists: list, tuple, range enumerate
  6. Loops: loop
  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 files IO
  14. Files Practice- Flashcard Quizzer
  15. Functions
  16. Functions Practice - Wordplay
  17. Classes
  18. Scrabble Cheater
  19. Course Closing

Let's Dive into

To do

人工智能

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

网络爬虫

爬虫的具体代码得根据网站不同而修改的,而Python这种灵活的脚本语言特别适合这种任务。同时Python还有强大的爬虫库比如Scrapy。使用Python这样的简单编程语言,你可以使用少量编程技能就可以爬取复杂的网站。

服务器端开发

服务器端编程,具有丰富的Web开发框架,如Django和TurboGears,快速完成一个网站的开发和Web服务。典型如国内的豆瓣、果壳网等;国外的Google、Dropbox等。

3D游戏开发

Python有很好的3D渲染库和游戏开发框架,有很多实用Python开发的游戏,如迪士尼卡通城、黑暗之刃。常用PyGame、PyKyra等和一个PyWeek的比赛。

图形界面开发

Python可编写桌面图形用户界面,还可以扩展微软的Windows,常用TK、GTK+、PyQt、Win32等。

网络编程

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