1. Python 简介
1.1 Python 的历史
Python 的创始人为吉多. 范罗苏姆(荷兰语: Guido van Rossum)
1989 年的圣诞节期间: 吉多. 范罗苏姆为了在阿姆斯特丹打发时间, 决心开发一个新的脚本解释程序, 作为 ABC 语言的一种继承. 之所以选中 Python 作为程序的名字, 是因为他是 BBC 电视剧 -- 蒙提. 派森的飞行马戏团的爱好者.
1991 年 2 月: 第一个 Python 编译器 (同时也是解释器) 诞生, 它是用 C 语言实现的(后面又出现了 Java 和 C# 实现的版本 Jython 和 IronPython, 以及 PyPy,Brython,Pyston 等其他实现), 可以调用 C 语言的库函数. 在最早的版本中, Python 已经提供了对 "类","函数","异常处理" 等构造块的支持, 同时提供了 "列表" 和 "字典" 等核心数据类型, 同时支持以模块为基础来构造应用程序.
1994 年 1 月: Python 1.0 正式发布.
- [[email protected] ~]# wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
- [[email protected] ~]# tar -xvf Python-3.7.3.tgz
- [[email protected] ~]# cd Python-3.7.3/
- [[email protected] Python-3.7.3]# ./configure --prefix=/usr/local/python37 --enable-optimizations
- [[email protected] Python-3.7.3]# make && make install
- [[email protected] ~]# VIM /etc/profile.d/python
- export PATH=$PATH:/usr/local/python37/bin
- [[email protected] ~]# source /etc/profile.d/python
- [[email protected] ~]# python3
- >>> import sys
- >>> print(sys.version_info)
- sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
- >>> print(sys.version)
- 3.7.3 (default, Apr 26 2019, 14:42:46)
- [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
- [[email protected] ~]# python hello.py
- hello world!
- [[email protected] ~]# python3 hello.py
- hello world!
- """
- 第一个 Python 程序 - hello, world!
- 向伟大的 Dennis M. Ritchie 先生致敬
- Version: 0.1
- Author: 阿龙
- """print('hello, world!')
- # print("你好, 世界!")
- print('你好', '世界')
- print('hello', 'world', sep=',', end='!\n')
- print('goodbye, world', end='!\n')
- [[email protected] ~]# python3 hello.py
- hello, world!
- hello, world!
- goodbye, world!
- Sublime 3
- import urllib.request,os;pf='Package Control.sublime-package';ipp=Sublime.installed_packages_path();urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler()));open(os.path.join(ipp,pf),'wb').write(urllib.request.urlopen('http://sublime.wbond.net/'+pf.replace('',' ')).read())
- Sublime 2
- import urllib2,os;pf='Package Control.sublime-package';ipp=Sublime.installed_packages_path();os.makedirs(ipp)ifnotos.path.exists(ipp)elseNone;urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler()));open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace('',' ')).read());print('Please restart Sublime Text to finish installation')
- import turtle
- turtle.pensize(4)
- turtle.pencolor('red')
- turtle.forward(100)
- turtle.right(90)
- turtle.forward(100)
- turtle.right(90)
- turtle.forward(100)
- turtle.right(90)
- turtle.forward(100)
- turtle.mainloop()
来源: http://www.bubuko.com/infodetail-3383297.html