Introduction to the interpreter for the introductory Python chapter

Source: Internet
Author: User

"Interpreter Start Mode"

The first way to start the interpreter is similar to starting the Unix shell, which interactively reads and executes each command when it is started by the standard input stream of the TTY device to which it is connected, and reads and executes the script from the file when the interpreter starts with a filename or a standard file input stream.

The second way to start the interpreter is to enter PYTHON–C command [ARG] ..., where command is one or more statements executed. Because Python expressions contain a variety of special characters, such as spaces, it is recommended to use a single quote string to represent the command.

Python can execute the module as a source file, using python–m module [ARG] ... to execute the files in the module.

"How to exit the interpreter"

The Python interpreter identifies both the Windows system and the UNIX system with the input control-d and control-z characters as the end of the script file run, with 0 as the state at which the script ends. You can use the Quit () function to leave the interpreter out of the currently running script when the input end-of-identity does not work.

"Parameters of the Interpreter"

The interpreter can get the file name and running parameters of the script to be run, both of which are saved to the string list argv variable. The argv module can be accessed by using the Import SYS command in the SYS module.   SYS.ARGV[0] is generally the script file name, if the script file name to the interpreter is '-' (indicates the standard input stream), Sys.argv[0] is set to '-'; When using '-C ' as the interpreter starts the way, Sys.argv[0] is set to '-C '; '-M ' to start the module, Sys.argv[0] is set to the local path full name of the module.

"Format of script file"

UTF-8

Introduction to the interpreter for the introductory Python chapter

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.