2 python介绍

1.Python介绍:龟叔

python的创始人为吉多·范罗苏姆(Guido van Rossum)1989年的圣诞节期间Guido开始写Python语言的编译器。Python这个名字,来自Guido所挚爱的电视剧Monty Python’s Flying Circus。

他希望这个新的叫做Python的语言,能符合他的理想:创造一种C和shell之间,功能全面,易学易用,可拓展的语言。

 

2.Python的发展史

1989年,Guido开始写Python语言的编译器。

1991年,第一个Python编译器诞生。它是用C语言实现的,并能够调用C语言的库文件。从一出生,Python已经具有了:类,函数,异常处理,包含表和词典在内的核心数据类型,以及模块为基础的拓展系统。

Granddaddy of Python web frameworks, Zope 1 was released in 1999

Python 1.0 - January 1994 增加了 lambda, map, filter and reduce.

Python 2.0 - October 16, 2000,加入了内存回收机制,构成了现在Python语言框架的基础

Python 2.4 - November 30, 2004, 同年目前最流行的WEB框架Django 诞生

Python 2.5 - September 19, 2006

Python 2.6 - October 1, 2008

Python 3.0 - December 3, 2008 (这里要解释清楚 为什么08年就出3.0,2010年反而又推出了2.7?是因为3.0不向下兼容2.0,导致大家都拒绝升级3.0,无奈官方只能推出2.7过渡版本)

Python 2.7 - July 3, 2010

In November 2014, it was announced that Python 2.7 would be supported until 2020, and reaffirmed that there would be no 2.8 release as users were expected to move to Python 3.4+ as soon as possible

Python 3.1 - June 27, 2009

Python 3.2 - February 20, 2011

Python 3.3 - September 29, 2012

Python 3.4 - March 16, 2014

Python 3.5 - September 13, 2015

Python 3.6 - 2016-12-23 发布python3.6.0版

 

3.Python 有哪些种类?

 

CPython

当我们从Python官方网站下载并安装好Python 2.7后,我们就直接获得了一个官方版本的解释器:CPython。这个解释器是用C语言开发的,所以叫CPython。在命令行下运行python就是启动CPython解释器。

CPython是使用最广且被的Python解释器。教程的所有代码也都在CPython下执行。

PyPy

PyPy是另一个Python解释器,它的目标是执行速度。PyPy采用JIT技术,对Python代码进行动态编译(注意不是解释),所以可以显著提高Python代码的执行速度。

绝大部分Python代码都可以在PyPy下运行,但是PyPy和CPython有一些是不同的,这就导致相同的Python代码在两种解释器下执行可能会有不同的结果。如果你的代码要放到PyPy下执行,就需要了解PyPy和CPython的不同点。

4.Python 2 or Python 3 ? 

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).

 

 

 

5.第一个python程序

 掌握Python代码的2种执行方式

  1.文件执行

  1. 用notepad++创建一个文件,输入以下代码
  2. print("Hello World!")
    print("Python好简单呀,我要学好挣大钱!")
  3. 保存为HelloWorld.py , 注意要强调.py后缀名的作用
  4. 进入cmd命令行,执行python HelloWorld.py, 看结果 (注意要解释文件名前面加python 的原因是要把代码交给python解释器去解释执行)
C:\Users\Administrator\Desktop>python HelloWorld.py
Hello World
学好挣大钱

 

 

# 后缀名对python没有影响
C:\Users\Administrator\Desktop>python HelloWorld
Hello World
学好挣大钱

 

 

 2.交互器执行:调试用的

演示在python交互器下 ,输出hello world !

要强调python交互器是主要用来对代码进行调试用的

 

C:\Users\Administrator\Desktop>python
Python 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)]
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> print("Hello World")
Hello World
>>>

 

 

6.精通各种语言的Hello World

C++

#include <iostream>
 int main(void)
 {
  std::cout<<"Hello world";
 }

 

C

#include <stdio.h>
int main(void)
{
printf("\nhello world!");
return 0;
}

 

JAVA

public class HelloWorld{
  // 程序的入口
  public static void main(String args[]){
    // 向控制台输出信息
    System.out.println("Hello World!");
  }
}

 

PHP

<?php  
             echo "hello world!";  
?>

 

Ruby

日本人开发的,敏感时期容易挨K

 puts "Hello world."

 

GO

package main

import "fmt"

func main(){

    fmt.Printf("Hello World!\n God Bless You!");

}

 

posted @ 2018-01-23 12:08  venicid  阅读(235)  评论(0编辑  收藏  举报