from __future__ import *

Iterating, updating, and changing are all states of development

Explain the meaning of the common methods of "_ future _" that are often seen in the code :

Each new version of Python adds some new functionality or makes some changes to the original functionality. Some changes are not compatible with the old version, that is, the code that runs normally in the current version may not run normally in the next version.
Python provides the __future__ module to import the features of the next new version into the current version, so we can test some features of the new version in the current version.

1. In order to adapt to the new string representation method of Python 3.x, in the 2.7 version of the code, you can use the new syntax of Python 3.x through unicode_literals, introducing:

from __future__ import unicode_literals

2. Exact division, the result of 2/4 is 0 by default, and the result after importing division is 0.5

from __future__ import division

3. Absolute import, its function is that when importing a module, if the same module is included in the current project directory, the standard library will be imported first, that is to say, if there is a time module in your current directory, import time still imports Python The official time standard library.

from __future__ import absolute_import

4.print can be used as a function. In Python2, the writing format of print is print xxx, in python3 it is print(xxx), and print_function can make python2 use the python3 format.

from __future__ import print_function

Note: In fact, the functions of these three functions are supplements made by python2 in order to adapt to the python3 format. If it is python3, it does not need to be imported.

References: python , and GolLong .