Reference Link: http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/ 001386820023084e5263fe54fde4e4e8616597058cc4ba1000
There are some incompatible changes in python2.7 to 3.x, and if you upgrade the Python version directly, it will result in some old Python code not executable; In order to solve this problem, the Python community has developed the __FUTURE__ module;
1. String compatibility
In python2.7, any created string object, such as A= ' str1 ', is represented by default as a string type, and if it needs to be converted to a Unicode code, you need to precede the string with u, that is, a=u ' str1 ';
In python3.x, any string created by default is Unicode code,
From __future__ import unicode_literalsprint ' \ ' xxx\ ' are Unicode? ', isinstance (' xxx ', Unicode) print ' u\ ' xxx\ ' is Unicode? ' , isinstance (u ' xxx ', Unicode) print ' \ ' xxx\ ' is str? ', isinstance (' xxx ', str) "print ' b\ ' xxx\ ' is str? ', isinstance (b ' xxx '), STR) results: ' xxx ' is Unicode? Trueu ' xxx ' is Unicode? True ' xxx ' is str? Falseb ' xxx ' is str? True
2. Division Compatible
Python2 Division of the floor, the default is to keep only the integer part, if you want to retain the fractional part, you need to
Using __future__ to achieve transitions from python2.7 to python3.x