The difference between P2 and P3
-Encode & string:
String:
P2:
Unicode v = U ' find the table ' is intrinsically stored in Unicode (Universal code)
(str/bytes) v = ' Find the table ' essence is stored in bytes
Py3:
str v = ' Find the table ' is essentially Unicode (universal code)
Bytes v = B ' find the table ' is essentially a byte store
Coding:
P2
-ASCII
File header can be modified #-*-encoding:utf-8-*-
P3:
'-utf-8
File header can be modified: #-*-encoding:utf-8-*-
Inheritance
P2: Classic class/New class
P3: New Class
The difference between using super ()
P2: A base class must be added to the actual parameters
P3: can be used directly without parameter calls
Range
P2:range/xrange
P3:range
Input
PY2:V1 = raw_input (' Please enter user name ')
Py3:v2 = input (' Please enter user name ')
Print
Py2:print ' xxxxx '
Py3:print (123)
-1/2 Results
P2: return 0
P3: Returns 0.5 without the difference between int and long
-true and False
Py2:true and False are two global variables in py2, which can be assigned values or other operations, with initial values of 1 and 0, respectively.
Although the modification violates Python's design principles, it is true that you can change
PY3: Modified this variable to make true and flase immutable
-Iterators
Py2: Many of the methods that return a list, such as range, the Dictionary object's Dic.keys (). Dic.values () method, Map\filter\zip;
And the iterator must implement the next method
Py3: Changed the method of returning the list to return iteration object, built-in __next__, do not need to implement next
-nonlocal
Py2: There is no way to declare the edge wave as a non-local variable in the nested function, only the function can find that declaration global variable
The Pye3:nonlocal method can be implemented
The difference between the Pyhon2 and Python3 of the knowledge point worth 200 dollars