Python has three ways to start. The simplest is to start the interactive interpreter, each input line of Python code to execute. Another way to start is to run Python Python script. The third way is to run in the IDE Python.
One. Interactive interpreter
1.Unix derivative systems (Linux, MacOSX, Solaris, FreeBSD, etc.)
(1) the implementation of the Python file search path added to the system
(2) in the shell terminal and type python (2.X) or python3.2 (3.X)
Started successfully, you see information about the interpreter, that Python's version number and platform information, and finally display the interpreter Python command prompt ">>>" waiting for input.
(1) Python installation path to the PATH environment variable.
(2) in the CMD console, you can enter Python.
Second, in order to run the script
1.Unix derivative versions
(1) command line operation. Using python script.py.
(2) Unix can automatically execute the script. The first line of the script with shell magic string:
#! / Usr / local / bin / python.
#! After the set is the full path to Python interpreter.
Can also be written #! / Usr / bin / env python. Where "/ user / bin / env" env command is the path. Different platforms may be inconsistent. With this line of string, then set the script executable, you can directly enter the file name (including suffix) to execute the script.
2.Windows environment in the command line, enter the script name, or double-click the script file can execute the script.
Script suffix can have two types of py, the other is pyw. There will be an implementation of the console before
Window, the latter does not.
3. The source file encoding with the first line in the file # -*- coding: encoding -*-
3.X default is UTF-8, 2.X default is ASCII
Third, the interactive startup file
When using the interactive interpreter, once again exit the interpreter comes in, do some operations before
Are not saved. You can use a startup file in the file to perform some common operations. Then
PYTHONSTARTUP then set the environment variable specified file path.
Fourth, the input and output redirection
The first is the redirected input.
The second and third are redirecting the output, just append the end of the third file in the specified content,
And two will be added to empty the contents of the file.
V. Detailed command line arguments
Detailed applies only to the CPython, other implementations may vary.
1. Command line syntax
python [-bBdEhiOsSuvVWx?] [-c command |-m module-name | script |
To be added ... ...