1 The difference between python2 and python3
1. Python3 uses stricter indentation, and space and tab cannot be mixed. In the indentation mechanism of Python2, 1 tab and 8 spaces are equivalent.
2. Python3's native support for Unicode characters, the use of ASCII code as the default encoding in Python2 leads to two types of string, str and unicode,
(#-*- encoding:utf-8 -*-)
3. All integrated new styles in Python3 For class object, there is a difference between old-style and new-style classes in python2,
type(x) and x.__class__ are the same result (new-style class),
old-style class (classic class) type(x) always returns <type'instance'>. This reflects that all instances of old-style classes are implemented through a single built-in type called instance.
4 Obsolete statement
python3 Obsolete statement print, exec is changed to the corresponding function
long integer type is abandoned by Python3, unified use of int
inequality operator "<>" is abandoned by Python3, unified use "!="
xrange function is abandoned by Python3, unified use range
The raw_input function was abandoned by Python3, the unified use of the input function
exception StandardError was abandoned by Python3, and the unified use of the Exception
round function. The return value difference 2 is int 3 is float
5 for loop
Python2, the for loop will modify the value of the external variable with the same name
Python3, the for loop will not modify the value of the external variable with the same name
6 Comparison
Operator Differences between Comparison Operators
Any two objects in Python2 can be compared 123 <'test' #True
Only objects of the same data type can be compared in Python3 123 <'test' # TypeError: unorderable types: int() <str ()