1.谁创造了Python:
Python的创始人为吉多·范罗苏姆。1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继承。
就这样,Python在吉多手中诞生了。实际上,第一个实现是在Mac机上。可以说,Python是从ABC发展起来,主要受到了Modula-3(另一种相当优美且强大的语言,为小型团体所设计的)的影响。并且结合了Unix-Shell和C的习惯。
目前吉多仍然是Python的主要开发者,决定整个Python语言的发展方向
2.什么是python
首先,我们普及一下编程语言的基础知识。用任何编程语言来开发程序,都是为了让计算机干活,比如下载一个MP3,编写一个文档等等,而计算机干活的CPU只认识机器指令,所以,尽管不同的编程语言差异极大,最后都得“翻译”成CPU可以执行的机器指令。而不同的编程语言,干同一个活,编写的代码量,差距也很大。
比如,完成同一个任务,C语言要写1000行代码,Java只需要写100行,而Python可能只要20行。
所以Python是一种相当高级的语言,Python崇尚优美、清晰、简单。
你也许会问,代码少还不好?代码少的代价是运行速度慢,C程序运行1秒钟,Java程序可能需要2秒,而Python程序可能就需要10秒。
那是不是越低级的程序越难学,越高级的程序越简单?表面上来说,是的,但是,在非常高的抽象计算中,高级的Python程序设计也是非常难学的,所以,高级程序语言不等于简单。
先看优点
再看缺点:
Python在一些公司的应用:
在此引用Python官方声明的文档:
In summary : Python 2.x is legacy, Python 3.x is the present and future of the language
Python 3.0 was released in 2008. The final 2.x version 2.7 release came out in mid-2010, with a statement of
extended support for this end-of-life release. The 2.x branch will see no new major releases after that. 3.x is
under active development and has already seen over five years of stable releases, including version 3.3 in 2012,
3.4 in 2014, and 3.5 in 2015. This means that all recent standard library improvements, for example, are only
available by default in Python 3.x.
Guido van Rossum (the original creator of the Python language) decided to clean up Python 2.x properly, with less regard for backwards compatibility than is the case for new releases in the 2.x range. The most drastic improvement is the better Unicode support (with all text strings being Unicode by default) as well as saner bytes/Unicode separation.
Besides, several aspects of the core language (such as print and exec being statements, integers using floor division) have been adjusted to be easier for newcomers to learn and to be more consistent with the rest of the language, and old cruft has been removed (for example, all classes are now new-style, "range()" returns a memory efficient iterable, not a list as in 2.x).
PRINT IS A FUNCTION
The statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old statement (PEP 3105). Examples:
Old:print "The sum is",2*2
New:print("The sum is",2*2)#you must use "()"
Old:print # Prints a newline
New:print() #you must call the print function
Old: print >>sys.stderr, "error_info"
New: print("fatal error", file=sys.stderr) #also you have cll the print function
Old: print (x, y) # prints repr((x, y))
New: print((x, y)) # Not the same as print(x, y)!
总结:Python2 是Python的过去版本,Python3才是这门语言的未来
1、下载安装包
https://www.python.org/downloads/
2、安装
默认安装路径:C:\python27
3、配置环境变量
【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中找到 变量名为Path 的一行,双击】 --> 【Python安装目录追加到变值值中,用 ; 分割】
如:原来的值;C:\python27,切记前面有分号
2、Mac下、Linux下
系统自带环境,无需配置,在termini输入以下代码可查看Python版本(各系统通用命令):python -V
Mac 和 Linux下:
创建一个文件名叫hello.py,并输入
print("Hello World!")
然后执行命令:python hello.py,输出
Hello World!
因为Python3 对Python2 的不完全兼容,所以可能出现代码在Python3 能运行,在Python缺不能运行的情况,如果需要明确指定python解释器的版本,那么就需要在 hello.py 文件的头部指定解释器,如下:
/usr/bin/env/python3/usr/bin/env/python3
print("HEllo World!")
ps:执行前需给予 hello.py 执行权限,chmod 755 hello.py
在交互器中执行
除了把程序写在文件里,还可以直接调用python自带的交互器运行代码,
Echo$ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World!")
Hello World
/usr/bin/env/python3
print("HEllo World!")
ps:执行前需给予 hello.py 执行权限,chmod 755 hello.py
在交互器中执行
除了把程序写在文件里,还可以直接调用python自带的交互器运行代码,
1
2
3
4
5
6
|
Echo~$ python
Python
2.7
.
10
(default,
Oct
23
2015
,
18
:
05
:
06
)
[GCC
4.2
.
1
Compatible Apple LLVM
7.0
.
0
(clang
-
700.0
.
59.5
)] on darwin
Type
"help"
,
"copyright"
,
"credits"
or
"license"
for
more information.
>>>
print
(
"Hello World!"
)
Hello World!
|