Python Learning notes (i)

Source: Internet
Author: User

Install Python on Windows

First, download the latest version of 2.7.9 from the official website of Python, the address is this: www.python.org

Http://www.python.org/ftp/python/2.7.9/python-2.7.9.msi

Then, run the downloaded MSI installation package, and tick all the components when you select the step of the installation component:

In particular, be careful to select pip and Add python.exe to Path , then go all the way "Next" to complete the installation.

The default is to install to the C:\Python27 directory, then open a command Prompt window, after typing python, there are two situations:

Situation One:

See the above screen, it shows that Python installation success!

You see the prompt indicates that we are already in the >>> Python interactive environment, you can enter any Python code, carriage return will immediately get the result of execution. You can now exit() exit the Python interactive environment by entering and returning to the command line window! )。

Situation two: Get an error:

‘python’不是内部或外部命令,也不是可运行的程序或批处理文件。

This is because Windows will be based on a Path path set by the environment variable to find python.exe , if not found, will be an error. If you omit the tick when you install Add python.exe to Path it, manually python.exe add the path you are in C:\Python27 to path.

If you do not know how to modify the environment variables, it is recommended to run the Python installer again, remember to tick Add python.exe to Path .

Two. Python interactive mode and command line mode

At first, in command-line mode, the command line under Windows, enter Python into interactive mode, execute Python code directly in interactive mode, exit interactive mode, enter exit () to return to the command line mode, The python file can be compiled in command-line mode (with a suffix of. py) and of course you have to CD to that file's directory first.

In Python's interactive command line to write programs, the advantage is that you can get results, the disadvantage is unable to save, the next time you want to run, you have to knock again. So, in the actual development, we always use a text editor to write code, finished, saved as a file, so that the program can be run repeatedly.

The text editor can be used sublime txt or notepad++,

Writing is to note that the code is indented, several spaces or tabs are OK, but keep it consistent.

Python Learning notes (i)

Related Article

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.