浏览Python官网
Python官网整合了与Python有关的许多资源。其中包括源码、教程、文档、社区等,甚至还包括了成功案例和新闻时事。
Python 定位
Python官网中,为Python制定的宣传语是
Python is a programming language that lets you work quickly and integrate systems more effectively.
Work Quickly
此处提到work quickly而不是run quickly。事实上Python
作为一门解释型语言,其运行速度必然比language C
等编译型语言慢。但Python
的长处并不在运行速度,而在于开发速度。
敏捷开发是现今十分流行的开发方式,在创业型公司中尤其流行。Python靠其极其强大的库和“胶水”能力,成为开发者的利器。
Python语法简洁,库的封装层度高,大大加速了开发者的开发效率。
Integrate System
此处提到的”integrate system”强调了Python的胶水能力。Python十分擅长将多种语言粘合在一起协同工作。
其中language C
与Python
粘合后的CPython
更兼备了两种语言的优点,成为潮流。
官网链接
About
在About中,网站介绍了Python的众多应用场景,从web应用到科学计算,应有尽有。网站还收录了各大著名网站对Python的简评。
About还提供了引向帮助文档、新手教程的部分链接
Download
Download页面提供了各个平台的Python下载方式。 Python是一门跨平台的语言,其可以通过解释器达到处处执行的效果。
在笔者所使用的GNU/Linux
系统中,Python是系统的重要组件之一,随系统自带而无需下载。
需要注意的是,Python2
和Python3
是不兼容的语言。从语法上到第三方库上都存在各种各样的差异。
以后的所有博客默认使用Python3
.
$ python3 --version
Python 3.5.2
Document
Document页面包含了从入门到进阶的各级教程。教程甚至有各种语言的翻译。
Others
其余的链接包含Python社区、成功案例和新闻时事等。
展望
若你成为了Python大神,你最想开发什么?
Web应用
略懂express.js
的使用。但一直想转用Python做后端和数据库。希望能用开发一些web应用,尤其是web游戏。
微信提供了一套Python接口。希望用此来写写微信端的页游,支持好友间的游戏,例如狼人杀等。
机器学习
Python有很多与机器学习有关的库,例如tensorflow
, scikit
等。
希望能学会机器学习,做做计算机视觉领域的应用。
课后习题
2-1 至 2-5
# 2-1
>>> msg = 'hello world'
>>> print(msg)
hello world
#2-2
>>> value = 5
>>> print(value)
5
>>> value += 5
>>> print(value)
10
## 2-3
>>> msg = 'Hello {}, would you like to learn some Python today?'.format('Benson')
>>> print(msg)
Helo Benson, would you like to learn some Python today?
# 2-4
>>> name = 'benson'
>>> print(name.lower()) # or print(name)
benson
>>> print(name.upper)
BENSON
>>> print(name.title)
Benson
# 2-5
>>> msg = 'Albert Einstein once said, "A person who never made a mistake never tried anthing new"'
>>> print()
Albert Einstein once said, "A person who never made a mistake never tried anthing new"
2-6 至 2-11
# 2-6 同2-5 将人名存入 famous_person中,创建显示的信息,存储于变量message中并显示
>>> famous_person = 'Albert Einstein'
>>> message = '{} once said,"who never made a mistake never tried anthing new"'.format(famous_person)
>>> print(message)
# 2-7
>>> special_name = '\t\nBenson\t\n'
>>> print(special_name)
Benson
>>> print(special_name.lstrip())
benson
>>> print(special_name.rstrip())
benson
>>> print(special_name.strip())
benson
# 2-8
>>> print(5+3)
8
>>> print(9-1)
8
>>> print(2*4)
8
>>> print(16/2)
8
# 2-11
>>> import this
# output is shown below for saving space
其中2-11的输出为
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!