Python Beginner's Road one: Python basics

Source: Internet
Author: User

From the video content of this section, learn the following knowledge points, which have not been learned before:

One, the Python version upgrade to 3.0 inevitability

    • In November, it is announced that Python 2.7 would is supported until 2020, and reaffirmed that there would is no 2. 8 release as users were expected to move to Python 3.4+ as soon as possible

The meaning of the above: the official Python statement----> Python2.7 series will be discontinued in 2020, and it is stated that there will be no 2.8 release of the official version, please move to the python3.4+ development environment as soon as possible.

This shows that we are now going to learn the 3.0 series, is very sensible (I am surrounded by most of the python2.7, for 3.0 of the difference is not much knowledge).

Ii. differences between Python3.5 and python2.7 versions installed on Windows systems

Python2.7: After installation, Homedir is C:\Python27 and can automatically add python2.7 homedir to the Windows Path environment variable at installation

Python3.5: After installation, homedir in C:\Users\ $username \appdata\local\programs\python\python35 and need to manually add Homedir to Windows The PATH environment variable. With the PIP to install the other packages, the command also changed: python3-m pip install flask

Three, print in python2.7 and python3.5 difference (this lesson only learned)

As we all know, in the development of python2.7, print has always existed as a grammatical structure, similar to return/while/if. In python3.5, however, the print statement was removed, adding the print () built-in function to achieve the same functionality.

Iv. user Input

4.1. Raw_input and input

In python2.7, there is also raw_input and input, which can be used to differentiate the input from "str" or "int", with a strict sense of distinction. However, in python3.0, only input is considered to be a unified str type.

4.2, Getpass

In order to hide the user input part of the interaction, you can use the Getpass module. As tested, execution is possible in the Python3 native IDE environment. But with the Pycharm run, will be stuck dead, no response.

V. Rules of Python Writing

5.1, Python is a beautiful and concise language, each line of code recommended no more than 80 characters

5.2, the module you write, preferably put to: Dist-packages directory, so that can be directly import. The reason: This directory is in the Sys.path list.

5.3. PY module in the current directory, with the highest priority when importing. The module with the same name will first import the. py module in the current directory.

5.4. About Chinese

In Python2.7, if there is no declaration encoding, the encoding error is reported when there is Chinese in the code. You need to add the coding code declaration to the text header. This is not necessary in Python3.5, and is more friendly to Chinese support. Of course, whether it's 2.7 or 3.X, it's best to get used to adding a coding statement to the file header!

As for data types, there is no significant difference.

Whistling, until now finish finishing the income, ashamed. Finish the finishing work as soon as possible next time, reserve time to preview new knowledge!

Python Beginner's Road one: Python basics

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.