1. The role of __future__ common in code:
Because Python is a community-driven open source and free development language that is not controlled by commercial companies, Python's improvements tend to be more aggressive and incompatible. In order to ensure that you have a smooth transition to the new version, Python specifically provides a __future__ module that lets you experiment with some features of the new version in the old version. For example, in Python 2.x, there are two cases of division, and if an integer is divided, the result is still an integer, and the remainder is thrown away, which is called "Floor division":
>>> 10 / 33
To do the exact division, you must turn one of the numbers into a floating-point number:
>>> 10.0 / 33.3333333333333335
In Python 3.x, all divisions are exact divisions, and the floor is represented by the addition of // :
$ python3python 3.3.2 ( Default, Jan 22 2014, 09:54:< Span class= "number" >40) [GCC 4.2.1 Compatible Apple LLVM 5.0 (Clang-500.2.79)] on Darwintype "Help", "credits" or "license" for more information.>>> Span class= "number" >10/33.3333333333333335>>> 10 //33
If you want to use the Python 3.x division directly in Python 2.7 code, you can pass __future__ the module division implementation.
Reference Beam Xuefeng Blog: http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/ 001386820023084e5263fe54fde4e4e8616597058cc4ba1000
Similar features seem to have six. For example from six.moves import xrange
2. The handling of exceptions in Python is
Try...except, try...finally, or fry...except...finally, no matter what, the sentence after finally will be executed
Raise ... By raise explicitly throwing an exception, once the raise statement is executed, the statement after raise cannot be executed.
3. Pycharm more lines in front of the same time add space, you can select multiple lines of code, press the TAB key. MultiRow Cancel indent At the same time, select multiple lines, press Shift+tab
Undo Step Ctrl + Z, multi-line annotation with ctrl+/
TensorFlow Learning Notes---1--python basic operations