如何学习Python
1、Python 历史
Python 的创始人为荷兰人吉多·范罗苏姆(Guido van Rossum)。1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为 ABC 语言的一种继承。之所以选中 Python 作为程序的名字,是因为他是 BBC 电视剧——蒙提·派森的飞行马戏团(Monty Python's Flying Circus)的爱好者。

2、ٴ,第一个 Python 编译器诞生。它是用C语言实现的,并能够调用C语言的库文件。
Python 2.0 于 2000 年 10 月 16 日发布,增加了实现完整的垃圾回收,并且支持 Unicode。
Python 3.0 于 2008 年 12 月 3 日发布,此版不完全兼容之前的 Python 源代码。不过,很多新特性后来也被移植到旧的 Python 2.6/2.7 版本。

3、简单的数学运算
整数相加,得到整数:
In [1]:
2 + 2
Out[1]:
4
浮点数相加,得到浮点数:
In [2]:
2.0 + 2.5
Out[2]:
4.5
整数和浮点数相加,得到浮点数:
In [3]:
2 + 2.5
Out[3]:
4.5

4、变量赋值
Python使用<变量名>=<表达式>的方式对变量进行赋值
In [4]:
a = 0.2
字符串 String
字符串的生成,单引号与双引号是等价的:
In [5]:
s = "hello world"s
Out[5]:
'hello world'
In [6]:
s = 'hello world's
Out[6]:
'hello world'
三引号用来输入包含多行文字的字符串:

5、s = """helloworld"""print s
helloworld
In [8]:
s = '''helloworld'''print s
helloworld
字符串的加法:
In [9]:
s = "hello" + " world"s
Out[9]:
'hello world'
字符串索引:

6、字符串索引:
In [10]:
s[0]
Out[10]:
'h'
In [11]:
s[-1]
Out[11]:
'd'
In [12]:
s[0:5]
Out[12]:
'hello'
字符串的分割:
In [13]:
s = "hello world"s.split()
Out[13]:
['hello', 'world']
查看字符串的长度:
In [14]:
len(s)
Out[14]:
11
