Exit the Python prompt when running Python

Source: Internet
Author: User
Tags python list

If you cannot exit the Python prompt during Python running or encounter some difficulties during related operations, you can use our article to learn about how to exit the Python prompt during Python running, and hope you will gain some benefits.

If you are using Linux/BSD shell, press Ctrl-d to exit the prompt. If it is in Windows command line, press Ctrl-z and then press Enter.

Select an editor

Before writing a Python program as a source file, we need an editor to write the source file. Selecting an editor is really important. You can select an editor just like you can select a car you will buy. A good editor will help you easily write Python programs, make your programming journey more comfortable, and help you reach your destination more quickly and securely ).

One of the basic requirements for the editor is the syntax brightening function. With this function, different parts of your Python running program are marked in different colors, in this way, you can better understand your program and visualize its operation.

If you are using Windows, we recommend that you use IDLE. IDLE has the syntax brightening function and many other functions, such as allowing you to run your program in IDLE. Note: Do not use Notepad-it is a bad choice, because it does not have the syntax brightening function, and more importantly, it does not support text indentation. We will see that text indentation is extremely important to us. A good editor, such as IDLE and VIM, will automatically help you do these tasks.

  • Introduction to three types of Python types
  • How to Implement element variables in the Python list
  • The Python splitter teaches you how to operate on an article.
  • How to run the Hello World Program in Python
  • Two import methods for the Python Module

If you use Linux/FreeBSD, you have many options. If you are an experienced programmer, you must be using VIM or Emacs. Undoubtedly, they are two of the most powerful editors. You will benefit from using them to write your Python program. I personally use VIM to write most of my programs.

If you are a beginner in programming, you can use Kate, which is also one of my favorite editors. As long as you are willing to spend time learning to use VIM or Emacs, I strongly recommend that you learn either of them, because they are extremely helpful in the long run.

Use source files

Now let's start programming again. When you learn a new programming language, the first program you write and run is usually a "Hello World" program, which has become a tradition. When you run the "Hello World" program, all it does is say "Hello World ". As Simon Cozens, who proposed the "Hello World" program, said, "It is a traditional spell of the god of programming and can help you better learn languages ."

Start the editor you selected, enter the following program, and save it as helloworld. py.

Example 2 use source files

 
 
  1. #!/usr/bin/python  
  2. # Filename : helloworld.py  
  3. print 'Hello World'   
  4.  

The above content is a brief introduction to some application operations on how to exit the Python prompt.

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.