3 minutes to write your first Python program

Source: Internet
Author: User
The content of this article is to write your The first Python programIn Python's interactive command-line write program, the advantage is that you can get the result, the disadvantage is unable to save, the next time you want to run, you have to knock again.

So, when actually developing, we always use a Python text editor to write code, write it down, save it as a file, so that the program can run repeatedly.

Now, we'll write the last ' Hello, World ' program with a text editor and save it.

So here's the question: where is the text editor strong?

Two text editors recommended:

One is Sublime Text, free to use, but no charge will pop up the prompt box:

One is notepad++, free to use, with Chinese interface:

Note that you can use whichever, but never use Notepad with Word and windows. Word does not save plain text files, and Notepad will be smart to add a few special characters (UTF-8 BOM) to the beginning of the file, resulting in an inexplicable error in the program running.

Once the text editor is installed, we can write our first Python program :

Print (' Hello, World ')

Note that there are no spaces in front of print . Then, select a directory, such as C:\work, save the file as hello.py, you can open the Command Line window, the current directory to switch to the hello.py directory, you can run the program:

C:\work>python Hello.pyhello, World

It can also be saved as a different name, such as first.py, but must end with a. py. In addition, the file name can only be a combination of English letters, numbers, and underscores.

If the file is not hello.py in the current directory, running Python hello.py will cause an error:

C:\users\ieuser>python hello.pypython:can ' t open file ' hello.py ': [Errno 2] No such file or directory

Above, it explains how to write your first Python program.

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.