A brief history of Python:
Python I think the features are simple, flexible and efficient.
Python Important version:
Python1991 year,
PYTHON2.4:2004, the same year the Django framework was born.
Python2.6:2008 year launch.
PYTHON2.7:2010 year launch.
python3.0: In parallel with the 2.6 launch, because of the python implementation of many years of low-level garbage accumulation (as the site has been running for many years, there are a lot of obsolete functions, files) so that language gradually lost its concise characteristics. So Python is optimized for Python, with big changes at the bottom. So that its 2.4 before the Python program can not be migrated to 3.0, the implementation is not smooth. So Python officially launches 2.6 as a 2x and 3x intermediate version, which can be compatible with two versions at the same time.
PYTHON3.5:2015 year launch.
Python official says python2.7 will be the best 2x version and will not update 2x. Python is also recommended to upgrade to 3x as soon as possible. Time 2020 years.
python:2x and 3x Difference
(1) 2.x print * *
3.x Print (* *)
2.7 can be either.
(2) 3.x some modules to change the name _. Most change to lowercase.
(3) 3.x does not support twisted module, is supported.
(4) 3.x2/1=0.5
(5) 3.x raw_input converted to input
(6) 3.x class Foo: Changed to Class Foo ()
Python output:
Print ("Hello word")
Print (\ n "Hello word2") \ n means line break
Run the Python declaration interpreter path under Linux:
1.#! /usr/bin/python3
2.#! /usr/bin/env python (the safest way to go to the entire environment variable to find Python, to avoid the impact of the version upgrade)
Python Variables and assignments:
A = 5 (variable can be easily called at any time)
A=3
B=a
A=5
Print (B,A) 3 5
In Python, the memory recycling mechanism, when B points to the variable value of the original A, points to not the path of a, but rather to the position of the A variable in Python memory (not the actual physical memory location, but the Python-virtualized memory, when Python is allocating space, will generate a table to record the variable location, similar to the MFS master) similar to Linux's soft and hard links. A re-assignment will reclaim the previous path, resulting in a new path.
Python variable name rule:
1. There is a clear representation.
2. Split with _ similar to: Wang_jian_hui = 20
3. Letters start with uppercase similar to: wangjianhui=20
4. Numbers, special symbols, key characters cannot be used as variable names.
ID (name) view Python memory location: ID (a), id (b)
Python User interaction:
Name=input ("Please input your name:")
2.x name=raw_input ("Please input your name:")
You can enable the user to interact dynamically and assign the input to the name variable.
Python conditional judgment and indentation:
If...elif...else ...
Age=int (Input ("Please input your Age:")) (int declares variable to be an integer)
A=18
If Age==a:
Print ("good")
Elif Age>a:
Print ("Your inout Age min")
Elif Age<a:
Print ("Your input Age Max")
Else
Print ("Input error")
Note that in Python, you force indent 4 spaces, and if you do not indent, you will get an error. Use indentation to make the code more visually visible and to differentiate scopes.
Python loop control:
While true: an infinite loop, true false or True indicates true, so input anything will be considered true, will go to execute, so is infinite loop.
Python Route 1 (first knowledge python)