Python Is a lightweight scripting language
characteristic :
install :
◆ Windows
http://www.python.org/
◆ Linux(Red Hat / CentOS)
Linux
# Python 2.7
$ sudo yum install -y python
# Python 3.6 (from EPEL)
$ sudo yum install -y epel-release
$ sudo yum install python36
# Python 3.6 (from IUS)
$ sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
$ sudo yum install -y python36u
◆ Linux(Ubuntu / Debian)
Linux
$ sudo apt-get install python2.7
◆ Linux Source code installation
CentOS 7.0 に Python 2.7.9 install
Linux
# yum -y install wget gcc zlib-devel gdbm-devel readline-devel
# yum -y install sqlite-devel openssl-devel tk-devel bzip2-devel
$ wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
$ tar zxvf Python-2.7.9.tgz
$ cd Python-2.7.9
$ ./configure --with-threads --enable-shared --prefix=/usr/local
$ make
$ sudo make altinstall
Python Operation method
◆ Windows
Global variables Path Specify the directory in .Windows Next ,[ Control panel ]-[ System ]-[ Detailed system settings ]-[ environment variable ] Add in python.exe Directory of ( for example : C:\Python27).
DOS command
C:\>set
Path=C:\WINDOWS\system32;C:\WINDOWS;...( A little )...;C:\Python27
C:\>python -V
Python 2.7.9
C:\>type hello.py
print "Hello world!"
C:\>python hello.py
Hello world!
C:\>
◆ Linux
environment variable PATH Add in python File directory ( for example :/usr/local/python/bin). If it is installed again /usr/bin Next , No need to specify PATH Of .
Linux
$ export PATH=$PATH:/usr/local/python/bin
$ python -V
Python 2.7.9
$ cat hello.py
print "Hello world!"
$ python hello.py
Hello world!
$ dialogue
Dialogue mode
Python With dialogue mode .
Linux
$ python
Python 2.7.9 (default, Dec 26 2014, 02:00:03)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 5+8
13
>>> 'Hello world!'
'Hello world!'
>>> a = 5
>>> b = 8
>>> a + b
13
>>> # Linux:Ctrl-D, Windows:Ctrl-Z Enter end
Enter... In conversation mode help(), You can view various help information .
Linux
$ python
>>> help()
Welcome to Python 2.7! This is the online help utility.
:
>>> import sys
>>> help(sys)
Help on built-in module sys:
NAME
sys
FILE
(built-in)
MODULE DOCS
http://docs.python.org/library/sys
DESCRIPTION
This module provides access to some objects used or maintained by the
interpreter and to functions that interact strongly with the interpreter.
About Python 3
2008 year Python 3.0 appear 、Python 2.x There is no complete compatibility 、 Now? Python 2 More people use it . And Python 2 The main differences are as follows .