TensorFlow Learning Notes---1--python basic operations

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.